dpjr86761 2014-10-18 21:34
浏览 70

upload_tmp_dir设置不正确 - php.ini

I want to upload a file to my server (Apache on RaspberryPi (raspbian) in my home network) over https and then write it to disk with PHP. I'm getting the move_uploaded_file(): Unable to move '/tmp/php2W6AMo' Permission denied Error. To solve this, I try to change the directory for the temporary upload files, but it's not working properly.

This Code:

<?php
ini_set('upload_tmp_dir', '/var/www/upload_tmp_dir/');
echo ini_get('upload_tmp_dir') .'
';

print_r($_FILES);

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "It worked.
";
} else {
    echo "Error!
";
}

?>

produces following output:

/var/www/upload_tmp_dir
Array
(
    [userfile] => Array
        (
            [name] => test.txt
            [type] => application/octet-stream
            [tmp_name] => /tmp/phpq9iDg3
            [error] => 0
            [size] => 124184
        )

)

The php.ini says this: /var/www/upload_tmp_dir. Same for phpinfo().

Why does it still upload the files to /tmp ? Is there anything I've overseen? Thank you for your help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 matlab有关常微分方程的问题求解决
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考