melting_dog Posted October 24, 2011 Share Posted October 24, 2011 Hi guys, I need a little help. I am running a site in XAMPP whilst I develop it locally. I am trying to upload an image file. Heres my code: $photo=$_POST['photo']; $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['photo']['name']); if(move_uploaded_file($_FILES['photo']['tmp_name'], $target_path)) { echo "The file has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } But I get these errors: Warning: move_uploaded_file(upload/ferriswheel.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/phpNwxq6I' to 'upload/ferriswheel.jpg' in /Applications/XAMPP/xamppfiles/htdocs/xampp/whatmycitywears/submitphotoprocess.php on line 53 Am I right in thinking this is some sort of issue with the temp directory? It seems to be putting it somewhere is XAMPSS folders rather then in my directory Any help would be great! Quote Link to comment https://forums.phpfreaks.com/topic/249673-file-upload-issues/ Share on other sites More sharing options...
melting_dog Posted October 24, 2011 Author Share Posted October 24, 2011 OK I get a new meesage now: Warning: move_uploaded_file(uploads/ferriswheel.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/xampp/whatmycitywears/submitphotoprocess.php on line 35 So I think I need to somehow set the permissions in XAMPP to allow upload? Quote Link to comment https://forums.phpfreaks.com/topic/249673-file-upload-issues/#findComment-1281687 Share on other sites More sharing options...
melting_dog Posted October 24, 2011 Author Share Posted October 24, 2011 Its ok - I've figured it out. I realised I had to set permissions on the upload directory to read/write on my computer Quote Link to comment https://forums.phpfreaks.com/topic/249673-file-upload-issues/#findComment-1281689 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.