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
- how to get wp-content folder in wordpress?
- 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?
- 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 to copy one folder to another folder recursively
- Disable to create folders for every years and months in uploads folder
- local folder permissions vs chown — security considerations
- How is a student directory best handled in WordPress?
- Creating directory in uploads: mkdir vs wp_mkdir_p
- Two identical wp-includes directories on server
- Second wordpress installation on subdirectory
- Install theme on multiple domains
- Include file from higher level
- 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
- Template Hierarchy tag-{slug}.php directory
- 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
- Subdomain redirects to subdirectory [closed]
- Correct folder permissions?
- How to make use of WP templates within a nested site structure?
- 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
- 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
- Hosting my WordPress site out of a subdirectory
- Theme file structure best practice
- 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?
- How to disable directory files from accessing?
- WordPress not handling subdirectory properly
- Wp-CLI not working with WordPress installed with composer
- How to visit php file in my custom directory under site root directory
- Does WordPress refer to any files outside of the main install folder (and database)?
- WordPress File Structure
- Getting Internal server in sub folder pages
- Moving wordpress from /dir to main folder
- Trying to setup a dev subdomain, but url loads as /dev/ instead
- Want to change my site root
- Best way to transfer WordPress install to root of directory when I’m ready to launch?
- add 360 (non-WordPress) tours in a subfolder with the same name as the main (WordPress)page of the 360 tours
- WordPress page for one specific page on Google Cloud hosted website?
- WordPress Bedrock breaking plugin links
- Editing Listings in a Business Directory
- New user – Create a folder
- How to install WordPress on sub directory in ubuntu 16.4 in same vhost with AngularJS
- Bedrock WordPress retro-porting to standard WP installation: is this allowed?
- How to Install WP to Subdomain but Serve on Subdirectory?
- Autoloading Classes in Plugins
- Change the WordPress files structure
- Downloadable content file structure
- WordPress makes 404 error when going to domain folder
- Moving wp-config.php when you have a second wordpress install
- Using same root header in subfolder wp blog – Header disapears on Single Posts
- Run multiple installs using the same wp-admin & wp-includes?
- Resource 404 error on multisite subdirectory install
- How do I get WP site to show in both root and sub-directory
- How to replace a wordpress installation in root directory with another in a subdirectory?
- Move WordPress with changed name ‘wp-content’
- Create Subfolder that always displays template file
- FTPS Uploads – wp-content cannot be found
- Permission functions within wordpress
- Index (Home) page not displayed when running wordpress in a subdirectory
- How do you create a development site into a subdirectory of the live site?
- WP white screen of death after duping a site that works fine on same server
- Hide/Remove Wp Directory /wp-content/uploads/
- Correct Syntax for uploading files to custom directory in WordPress
- Moving wordpress from TLD to sub-folder (URL structure only)
- @font-face Paths Don’t Seem to be working properly
- unabled to link all the pages