简体   繁体   English

move_uploaded_file()无法用于视频上传

[英]move_uploaded_file() not working for video upload

I know there are a lot of posts regarding this problem, however I feel I have taken all steps which were referred in previous answers and I have still had no luck. 我知道有很多关于此问题的文章,但是我觉得我已经采取了先前答案中提到的所有步骤,但我仍然没有运气。

I am trying to upload a video file which is 10MB and I have made changes in both my php.ini and .htaccess files, neither of which have rectified my problem: 我正在尝试上传一个10MB的视频文件,并且对php.ini.htaccess文件都进行了更改,但都没有纠正我的问题:

.htaccess .htaccess

# Restrict the maximum upload size to 32MB
php_value upload_max_filesize 32000000000
php_value post_max_size 32000000000

# Compensate for slow connection times, otherwise video uploads may not complete
php_value max_execution_time 99999999
php_value max_input_time 99999999

I know for a fact that the FILE data is getting passed correctly as a) the file contents reflects what I've uploaded and b) My upload conditions are satisfied right up to the block where move_uploaded_file() is called. 我知道FILE数据已正确传递,因为a)文件内容反映了我上传的内容,b)直到调用move_uploaded_file()的块都满足了我的上传条件。

$_FILE contents $ _FILE内容

array(1) {
["video_file"]=>
    array(5) {
      ["name"]=>
        string(11) "pump2_c.mp4"
      ["type"]=>
        string(9) "video/mp4"
      ["tmp_name"]=>
        string(14) "/tmp/php301tts"
      ["error"]=>
        int(0)
      ["size"]=>
        int(8368613)
    }
}

When I call for my video file to be moved I run 当我要求移动视频文件时,我会运行

move_uploaded_file($_FILES['video_file']['tmp_name'], './public/video/' . $_FILES['video_file']['name']);

However, whenever I var_dump() the result of the method it always returns false , does anybody have any ideas where I am going wrong? 但是,每当我var_dump()方法的结果始终返回false ,有人对我要去哪里出错有任何想法吗?

In order for move_uploaded_files() to run correctly on your script, the destination folder for the uploaded files has to be chmod 777 , which means 'Everybody can read, write and execute in this folder'; 为了使move_uploaded_files()在脚本上正确运行,上传文件的目标文件夹必须为chmod 777 ,这意味着“每个人都可以在此文件夹中读取,写入和执行”; because PHP is logged as 'Public' and thus cannot write in a folder with no public write access. 因为PHP记录为“公共”,因此无法在没有公共写访问权的文件夹中进行写操作。

You can perform such actios by typing chmod -R 777 /your/upload/folder on Unix console or using the Folder Properties Menu on Windows. 您可以通过在Unix控制台上键入chmod -R 777 /your/upload/folder或在Windows上使用“文件夹属性”菜单来执行此类actios。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM