简体   繁体   中英

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:

.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 contents

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?

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'; because PHP is logged as 'Public' and thus cannot write in a folder with no public write access.

You can perform such actios by typing chmod -R 777 /your/upload/folder on Unix console or using the Folder Properties Menu on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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