PHPPOST方法上传
PHP POST method upload
我无法调试为什么我的文件上传处理不起作用。我在我的页面上创建了一个 HTML5 文件上传器,它调用我的 upload.php.
upload.php
// File should be saved in same folder as upload.php
$uploaddir = '/';
$uploadfile = $uploaddir . basename($_FILES['fileToUpload']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
我的调试结果显示如下:
move_uploaded_file 似乎 return 错误,因此无法将上传的文件从临时位置移动到我指定的位置。
我已确保设置我的 upload.php 所在的文件夹的权限以及文件应保存到 777 的位置。
问题
有什么方法可以获取有关文件未保存原因的更多信息,以帮助我了解我做错了什么?
// File should be saved in same folder as upload.php
$uploaddir = '/';
/something
是一个 absolute path; $uploaddir 指向文件系统的根目录(这与网络服务器的 document_root 不同)。网络服务器进程很可能在那里没有写权限。
看看 __DIR__ "constant" 在 http://php.net/language.constants.predefined
我无法调试为什么我的文件上传处理不起作用。我在我的页面上创建了一个 HTML5 文件上传器,它调用我的 upload.php.
upload.php
// File should be saved in same folder as upload.php
$uploaddir = '/';
$uploadfile = $uploaddir . basename($_FILES['fileToUpload']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
我的调试结果显示如下:
move_uploaded_file 似乎 return 错误,因此无法将上传的文件从临时位置移动到我指定的位置。
我已确保设置我的 upload.php 所在的文件夹的权限以及文件应保存到 777 的位置。
问题 有什么方法可以获取有关文件未保存原因的更多信息,以帮助我了解我做错了什么?
// File should be saved in same folder as upload.php
$uploaddir = '/';
/something
是一个 absolute path; $uploaddir 指向文件系统的根目录(这与网络服务器的 document_root 不同)。网络服务器进程很可能在那里没有写权限。
看看 __DIR__ "constant" 在 http://php.net/language.constants.predefined