PHP、コードスニプトを使用してファイルをアップロードしようとしています
$upload_path = "/var/upload/" . $_FILES['mfile']['name'];
if(move_uploaded_file($_FILES['mfile']['tmp_name'], $upload_path))
echo "file uploaded";
else
echo "upload failed";
注:/ var / uploadディレクトリーが存在し、777権限を持っていることに注意してください。
コードは「アップロードに失敗しました」と出力します
/ var / uploadディレクトリを確認すると、ファイルf_505bf77bd8a0f_mypdf.pdfがあります。何が悪かったのか?
追加されたログ(lolerの要求による):
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: showdebug in /Volumes/data/htdocs/ebeu/upload.php on line 558, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: showdebug in /Volumes/data/htdocs/ebeu/upload.php on line 559, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: accessories in /var/www/my/web/folder/myupload.php on line 21, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: pmaterial in /var/www/my/web/folder/myupload.php on line 27, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: occupation_bwc in /var/www/my/web/folder/myupload.php on line 33, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: occupation_bwc in /var/www/my/web/folder/myupload.php on line 75, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: occupation_spec in /var/www/my/web/folder/myupload.php on line 75, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: babycarrier in /var/www/my/web/folder/myupload.php on line 78, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: accessories_all in /var/www/my/web/folder/myupload.php on line 79, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: pmaterials_all in /var/www/my/web/folder/myupload.php on line 80, referer: http://localhost/upload/test/upload.php
var_dump($ _ FILES)を追加しました
array(1) {
["mfile"]=>
array(5) {
["name"]=>
string(23) "mypdf.pdf"
["type"]=>
string(15) "application/pdf"
["tmp_name"]=>
string(26) "/var/tmp/phpUl6k50"
["error"]=>
int(0)
["size"]=>
int(478704)
}
}