divadiva Posted June 23, 2008 Share Posted June 23, 2008 Experts I have two files upload_file.php and uploader.php in a directory Upload. First file is upload_file.php <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="1000" /> Upload File: <input name="uploadedfile" type="file" /> <br /> <input type="submit" value="Upload File" /> </form> Second file uploader.php <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); print"$target_path"; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }?> When I run upload.php I get the basic form which asks me to select a file .When I select a file it gives me this error: Warning: move_uploaded_file(uploads/gagantest.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\upload\uploader.php on line 6 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php6E.tmp' to 'uploads/abc.txt' in C:\wamp\www\upload\uploader.php on line 6 There was an error uploading the file, please try again! I have been trying to resolve it bbut unable to do that so far.Please help me out. Link to comment https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/ Share on other sites More sharing options...
graham23s Posted June 23, 2008 Share Posted June 23, 2008 i think: $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); should be: $target_path = $target_path . basename( $_FILES['uploadedfile']['tmp_name']); try that Graham Link to comment https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/#findComment-572525 Share on other sites More sharing options...
divadiva Posted June 23, 2008 Author Share Posted June 23, 2008 Thankyou for replying. But I still get same error.Please suggest me something. Link to comment https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/#findComment-572528 Share on other sites More sharing options...
divadiva Posted June 23, 2008 Author Share Posted June 23, 2008 I got that.The issue was that the folder"UPLOAD" didnt had "uploads" folder in it where the new file will be stored. Link to comment https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/#findComment-572533 Share on other sites More sharing options...
graham23s Posted June 23, 2008 Share Posted June 23, 2008 i was about to say that lol good you got it sorted mate Graham Link to comment https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/#findComment-572534 Share on other sites More sharing options...
iversonm Posted June 24, 2008 Share Posted June 24, 2008 you need to change the permissions on your folder i had the same problem awhile back, so again jsut change the permission and it should work well nevermind lol Link to comment https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/#findComment-572793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.