问题
I really can't figure this one out, just got a basic upload script but the file wont upload.
Form
=> enctype is set
print_r($_FILES['Product_Thumb'])
=> [Product_Thumb]
=> Array (
[name] => prototype.js
[type] => application/x-javascript
[tmp_name] => /tmp/phpXzL6CT
[error] => 0
[size] => 139854 ))
I did set the permissons (-R) to 777 on the upload folder.
Changed the owner:group to www-data:www-data.
Mkdir works on the exact path I used for the upload file.
Tried different files, tried another folder, hardcoded the destination filepath, still doesnt work.
I see the file in /var/tmp/ but the moving is just not working, no error nothing at all.
Am I really overlooking something?
Thanx in advance!
======================================================================= Debug output:
Debug: tmp file:/tmp/phpgYOo9a
Debug: target directory: /var/www/clubgevoel/public/img/producten/
Debug: real target: /var/www/clubgevoel/public/img/producten
Debug: source readable:
Debug: target is_dir: yes
Debug: target writable: yes
Debug: move: bool(false)
回答1:
Full file quota on the server?
回答2:
move_uploaded_file should issue a warning if it fails(i.e. returns false). Make sure to test the uploading script with display_errors to On an error_reporting to ALL, like this:
ini_set('display_errors', 1);
error_reporting(-1);//or error_reporting(E_ALL); (http://de2.php.net/manual/en/function.error-reporting.php)
These lines should be placed before anything else in your script. This way you could at least discover the reason for the error
回答3:
i guess y are using ablolute path as destination.Try the relative one
回答4:
Let's add more debug output.... What does
// "also tried: move_uploaded_file($_FILES['Product_Thumb']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/clubgevoel/public/img/producten/2.jpg');"
error_reporting(E_ALL); ini_set('display_errors', 1);
$targetDir = $_SERVER['DOCUMENT_ROOT'] . '/clubgevoel/public/img/producten/';
$realTargetDir = realpath($targetDir);
ini_set('display_errors', 1);
echo '<pre>Debug: tmp file:', htmlspecialchars($_FILES['Product_Thumb']['tmp_name']), "</pre>\n";
echo '<pre>Debug: target directory: ', htmlspecialchars($targetDir), "</pre>\n";
echo '<pre>Debug: real target: ', htmlspecialchars($realTargetDir), "</pre>\n";
echo '<pre>Debug: source readable: ', is_readable($_FILES['Product_Thumb']['tmp_name']), "</pre>\n";
echo '<pre>Debug: target is_dir: ', is_dir($targetDir) ? 'yes':'no', "</pre>\n";
echo '<pre>Debug: target writable: ', is_writeable($targetDir) ? 'yes':'no', "</pre>\n";
$b = move_uploaded_file($_FILES['Product_Thumb']['tmp_name'], $targetDir. '2.jpg');
echo '<pre>Debug: move: '; var_dump($b); echo "</pre>\n";
print?
回答5:
Debug: tmp file:/tmp/phpgYOo9a
Debug: target directory: /var/www/clubgevoel/public/img/producten/
Debug: real target: /var/www/clubgevoel/public/img/producten
Debug: source readable:
Debug: target is_dir: yes
Debug: target writable: yes
Debug: move: bool(false)
来源:https://stackoverflow.com/questions/2198501/php-move-uploaded-file-yet-another-not-working