ok, im using the move_uploaded_file function to sore the images in a directory on my server when the user uploads the pictures. But, at the same time, i want that picture to be saved in a diffrent directory as well. So here is the original code file_exists(DIR "files/$img.jpg") ) { if (is_uploaded_file($files['Users']['pic']['tmp_name'])) { move_uploaded_file($files['User']['pic']['tmp_name'], DIR "files/$img.jpg"); PHP: and now, i want the same picture thats beeing uploaded to be saved in files/backup so here is what I tried: file_exists(DIR "files/$img.jpg") ) { if (is_uploaded_file($files['Users']['pic']['tmp_name'])) { move_uploaded_file($files['User']['pic']['tmp_name'], DIR "files/backup/$img.jpg"); move_uploaded_file($files['User']['pic']['tmp_name'], DIR "files/backup/$img.jpg"); PHP: the files are uploading fine to the "files" directory but not uploading to the "files/backup" directoy. Any help? Thanks, SP360
In is_uploaded_file() and move_uploaded_file(), you're using two different variables. I guess it's a typo. $files['Users'], and $files['User']. Also, in your second code, you're attempting to move the same file twice to the same location? Use move_uploaded_file() once to move the file to the main folder, and then use copy() to create a backup in a diffent folder.
It seems u r uploading both the files in same folder. Plz. chk. the move_uploaded_file() in both statements.