The rename
function does this
rename('image1.jpg', 'del/image1.jpg');
If you want to keep the existing file on the same place you should use copy
copy('image1.jpg', 'del/image1.jpg');
If you want to move an uploaded file use the move_uploaded_file
, although this is almost the same as rename
this function also checks that the given file is a file that was uploaded via the POST
, this prevents for example that a local file is moved
$uploads_dir = '/uploads'; foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } }
code snipet from docs
Related Posts:
- Compare 2 directories in windows
- Count how many files in directory PHP
- Create a folder if it doesn’t already exist
- how to get wp-content folder in wordpress?
- get_template_directory() vs bloginfo( ‘template_directory’ ) vs TEMPLATEPATH
- Change upload directory for PDF files
- What’s the purpose of index.php in wp-content directory? [duplicate]
- How do I serve static content on same domain as WordPress
- Can I change get_template_directory_uri()?
- Namespacing WordPress project according to FIG standards
- Custom Post Type Archive in Sub Folder
- How to point my domain to a WordPress install in a sub-directory?
- Can I put my WordPress theme files in another folder?
- Multiple domains for multiple single installs
- Does wordpress allow me to add a php file to the root directory to execute custom scripts?
- How to Create Hierarchical Directory for Nation Wide Mental Health Services
- How to create new folder in wp-content root same like upload folder?
- How do I set up single sign on for multiple WP installs across the same domain?
- Why doesn’t WP_PLUGIN_DIR definition use DIRECTORY_SEPARATOR?
- How to copy one folder to another folder recursively
- issues including a file from a plugin directory
- Disable to create folders for every years and months in uploads folder
- local folder permissions vs chown — security considerations
- What’s the proper way to use wp_enqueue_script/style?
- How is a student directory best handled in WordPress?
- Creating directory in uploads: mkdir vs wp_mkdir_p
- How would you detect if WordPress is installed in a subdirectory (not root)?
- Cant get wordpress to work on subdirectory
- Two identical wp-includes directories on server
- What is the recommend directory in which I can upload a new library?
- Second wordpress installation on subdirectory
- Install theme on multiple domains
- How to create an Online Dictionary Using WordPress? [closed]
- Include file from higher level
- how to create a folder in wordpress
- wordpress blog in subdirectory or subdomain
- Accessing WordPress installation in its own directory at domain root
- Change the actual (or viewable) WordPress directory structure
- Right permissions to WordPress directory
- Can I install a new WordPress site inside a sub-directory of an existing WordPress site?
- Template Hierarchy tag-{slug}.php directory
- Accessing site’s root from themes folder
- more than one upload directory?
- Custom location for attached images
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- Change directory of javascript files
- Theme in wp-content but my index.php search theme files in root
- get_query_var not working for subdirectory
- How can I have nginx serve WordPress at /blog?
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Subdomain redirects to subdirectory [closed]
- Correct folder permissions?
- How to make use of WP templates within a nested site structure?
- Plugins will only be installed with 777 on folder. Solution?
- How to create directory using username within theme
- 2 WordPress sites in 2 sibling folders on one domain
- Main WP page and subfolder WP with the same name. How to prioritize for main Wp
- subdirectory index.php is not working
- Auto-create a post with last 10 images in WordPress directory
- Accessing an image folder inside public web directory
- Copy Folder to another Folder using WP Filesystem
- Unable to update WordPress or install plugins/themes
- Session Expired when WordPress Address (URL) and Site Address (URL) are different
- After changing wp from subdirectory to root I can’t preview any changes to a page or post
- Moved WordPress site to new server, directory permissions not working correctly
- Moving from one test to multiple final environments
- WordPress in a sub directory but not images
- Should I install blog on subdomain or subdirectory?
- Hiding Directory Path
- Moving WP from /blog to root directory
- Should custom directories be created under the wp-content directory?
- Use of Folders within WordPress
- Folder keeps popping up in my public_html directory and overriding WordPress page structure
- Hosting my WordPress site out of a subdirectory
- Theme file structure best practice
- Clean installation missing its /wp-content folder
- PHP in CSS file?
- Path in dev server works; same path in prod server is broken
- What is wp-admin/meta for?
- google xml sitemap won’t work on directory install
- wp-mail attachment is not sent for no reason?
- What plugins create a directory on the root directory of WordPress? [closed]
- How can i shift my chosen posts to a subdirectory?
- Where to put robot.txt and sitemap.xml for wordpress installed in its own directory
- Automating WP application directory creation (domain name passed as a variable argument)
- How to disable directory files from accessing?
- Move WordPress from Root to Subfolder
- WordPress not handling subdirectory properly
- Wp-CLI not working with WordPress installed with composer
- Can I have a php site on subdirectory of WordPress?
- Plugin could not be deleted due to an error: Unable to locate WordPress Plugin directory
- Moving wordpress from TLD to sub-folder (URL structure only)
- @font-face Paths Don’t Seem to be working properly
- Multisite Sub-directories Installation
- Could moving my WordPress installation from /var/www/html/ to /var/www/ break the application?
- Get a list of folders inside uploads directory
- unabled to link all the pages
- Changing WordPress folder generates CSS issues?
- How to link the path of a folder situated in public.html for a random video player?
- How to have WordPress in a sub-folder but hosted in a different place?