php - move_uploaded_file():无法移动

时间:2017-08-05 00:29:57

标签: php file upload directory temp

我试图像这样使用move_uploaded_file

if (move_uploaded_file($_FILES['file1'.$username]['tmp_name'], 'images') && move_uploaded_file($_FILES['file0'.$username]['tmp_name'], 'images')) {

...

我收到错误:

move_uploaded_file(): Unable to move '/tmp/phpHNeWpt' to 'images' in /home1/eamondev/public_html/sneekback/respond.php on line 99

我已尝试将images文件夹的权限更改为777,但该功能无效。感谢。

1 个答案:

答案 0 :(得分:1)

您不能只指定要将文件移动到的目录,您必须输入要在该目录中调用该文件的名称:

move_uploaded_file($_FILES['file0']['tmp_name'], __DIR__.'/images/'.basename($_FILES['file0']['name'])