hanlonj Posted July 1, 2007 Share Posted July 1, 2007 Hi, The following code is supposed to upload a file to a directory on my local testing server called "upload_directory". It get's it's info from a simple file upload form. It echoes to the screen that "File was moved!" but when I check if it has been moved, it hasn't. Any ideas? <?php $file_dir = "..\upload_directory"; foreach ($_FILES as $file_name => $file_array){ echo "path: ".$file_array['tmp_name']. "<br>\n"; echo "name: ".$file_array['name']. "<br>\n"; echo "type: ".$file_array['type']. "<br>\n"; echo "size: ".$file_array['size']. "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])){ move_uploaded_file($file_array['tmp_name'], "\$file_dir\$file_array['name']") or die ("Couldn't Copy!"); echo "File was moved!<br><br>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/57973-file-upload-problem/ Share on other sites More sharing options...
realjumper Posted July 1, 2007 Share Posted July 1, 2007 Have you checked the permissions on 'upload_directory'? Link to comment https://forums.phpfreaks.com/topic/57973-file-upload-problem/#findComment-287431 Share on other sites More sharing options...
hanlonj Posted July 2, 2007 Author Share Posted July 2, 2007 Quote Have you checked the permissions on 'upload_directory'? Yes, it's just on my local machine at the moment so I presume the windows default setting for folders will suit? Just to be sure I have opened it up for sharing and it still doesn't work.Is there any obvious bug in the code? stoney Link to comment https://forums.phpfreaks.com/topic/57973-file-upload-problem/#findComment-288333 Share on other sites More sharing options...
jagat21 Posted July 3, 2007 Share Posted July 3, 2007 Hi, Try this..... $file_dir = "../upload_directory/"; foreach ($_FILES as $file_name => $file_array) { echo "path: ".$file_array['tmp_name']. "<br>\n"; echo "name: ".$file_array['name']. "<br>\n"; echo "type: ".$file_array['type']. "<br>\n"; echo "size: ".$file_array['size']. "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], $file_dir . $file_array['name']) or die ("Couldn't Copy!"); echo "File was moved!<br><br>"; } } Link to comment https://forums.phpfreaks.com/topic/57973-file-upload-problem/#findComment-288594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.