我正在使用Fedora 16,PHP5.x和Apach2.x
$target_path = "/var/www/html/mysite/uploads/";
$target_path = $target_path . basename( $_FILES['photo_video']['name']);
if(move_uploaded_file($_FILES['photo_video']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['photo_video']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
当我尝试上传时,我总是收到消息:
警告:move_uploaded_file(/var/www/html/mysite/uploads/PNGWallpaper.png):无法打开流:第44行/var/www/html/mysite/modules/content/cj_c.php中的权限被拒绝调用堆栈:0.0002 132524 1. {main}()/var/www/html/mysite/index.php:0 0.0016 153684 2. include_once('/ var / www / html / mysite / modules / content / cj_c.php' )/var/www/html/mysite/index.php:36 0.0022 160500 3. move_uploaded_file()/var/www/html/mysite/modules/content/cj_c.php:44警告:move_uploaded_file():无法移动'第44行/var/www/html/mysite/modules/content/cj_c.php中的/ tmp / phpiS3dQA'到'/var/www/html/mysite/uploads/PNGWallpaper.png'调用堆栈:0.0002 132524 1. { main}()/var/www/html/mysite/index.php:0 0.0016 153684 2. include_once('/ var / www / html / mysite / modules / content / cj_c.php')/ var / www / html / mysite / index.php:36 0.0022 160500 3. move_uploaded_file()/var/www/html/mysite/modules/content/cj_c.php:44上传文件时出错,请重试!
文件或文件夹权限:
drwxrwxrwx. 465 root root 36864 Apr 6 23:20 tmp
drwxrwxrwx. 2 knel knel 4096 Apr 6 22:47 uploads
的php.ini
file_uploads = On
max_file_uploads = 20
检查用户php正在运行
php> echo exec('whoami');
knel
谁可以向我提出解决方案?
答案 0 :(得分:3)
权限被拒绝意味着运行PHP的用户没有对目标路径中某个目录的写权限(/ var / www / html / mysite / uploads /)
您可以使用this工具检查目标目录下完整路径的权限。
答案 1 :(得分:0)
我遇到了同样的问题。
我的解决方案:确保目标文件夹包含" x"权限(700),不仅是写权限。