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>"; } } ?> Quote Link to comment 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'? Quote Link to comment Share on other sites More sharing options...
hanlonj Posted July 2, 2007 Author Share Posted July 2, 2007 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 Quote Link to comment 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>"; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.