我正在使用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):无法打开流:权限被拒绝(在/var/www/html/mysite/modules/content/cj_c.php的第44行)调用堆栈: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():无法将'/tmp/phpiS3dQA'移动到'/var/www/html/mysite/uploads/PNGWallpaper.png'(在/var/www/html/mysite/modules/content/cj_c.php的第44行)调用堆栈: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
谁能给我提供解决方案?
PNGWallpaper.png
是否已经存在于uploads
目录中? - Tim