TheFilmGod Posted August 31, 2007 Share Posted August 31, 2007 <?php echo "The uploaded file is: ", $_FILES['text_file']['tmp_name'], "<br />"; $filename=$_FILES['text_file']['name']; $filesize=$_FILES['text_file']['size']; $directory='sc/docs/'; $uploadfile = $directory . $filename; echo "The moved file is: $uploadfile<br />"; if (move_uploaded_file($_FILES['text_file']['tmp_name'], $uploadfile)) { echo "The file is valid and was successfully uploaded.<br />"; echo "The $filename, is $filesize bytest.<br />"; } ?> Error: Warning: move_uploaded_file(sc/docs/Student Council dates 07-08.doc) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/i/n/t/internetknight/html/sc/test2.php on line 20 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php7GhOkw' to 'sc/docs/Student Council dates 07-08.doc' in /home/content/i/n/t/internetknight/html/sc/test2.php on line 20 Link to comment https://forums.phpfreaks.com/topic/67513-solved-upload-file/ Share on other sites More sharing options...
TheFilmGod Posted September 1, 2007 Author Share Posted September 1, 2007 I got it to work. I made the directory path wrong. I made it from the root instead of the current directory the file was in! Dah! Link to comment https://forums.phpfreaks.com/topic/67513-solved-upload-file/#findComment-338999 Share on other sites More sharing options...
Fadion Posted September 1, 2007 Share Posted September 1, 2007 Ok glad u fixed it. One thing i notices is spaces in filenames. The files will work but they're not recomended (espacially linux). Consider trimming those or converting to underscore: $filename=str_replace(' ', '_', $_FILES['text_file']['name']); //will echo "my_file_without_spaces.doc" Link to comment https://forums.phpfreaks.com/topic/67513-solved-upload-file/#findComment-339003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.