Jump to content

[SOLVED] upload file


TheFilmGod

Recommended Posts

<?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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.