我正在使用 Fedora 16、PHP5.x 和 Apache2.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
谁能给我建议解决方案?