我正在尝试使用此 PHP 脚本上传文件(图像),但出现错误。是的,我知道这里还有其他问题会问同样的问题,但我没有发现其中任何一个有用。
这是我的脚本(简短版):
//*** FILE IS NAMED 'imageUpload' IN THE INC FOLDER ***
$image_name = addslashes($_FILES['image']['name']);
$image_tmpName = $_FILES['image']['tmp_name'];
$location = "usr/profile/$image_name";
move_uploaded_file($image_tmpName,'../img/'.$location);
这是我的文件树(CAPITOLS-folders,lower-file):
1. IMG
-USR
*PROFILE
2. INC
-imageUpload.php
我得到的错误:
Warning: move_uploaded_file(../img/usr/profile/Cheese.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/35/9611635/html/chsyearbook/inc/imageUpload.php on line 12
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuLkkjE' to '../img/usr/profile/Cheese.jpg' in /home/content/35/9611635/html/chsyearbook/inc/imageUpload.php on line 12
现在这些错误清楚地表明该目录不存在,但我向你保证,我现在正在查看它。
我认为这可能是 PHP.ini 文件的问题。如果是这样,这里是 PHP.ini(为什么不呢,嗯?)
max_execution_time = 60;
memory_limit = 256M;
upload_max_filesize = 256M;
post_max_size = 256M;