user4353824
user4353824

Reputation:

move_uploaded_file because of the upload_max_filesize

EDIT: the problem is that the video size is bigger than the upload_max_filesize but i already changed that to 125M in php.ini but when i echo the value using ini_get it says it's still 2M although i changed it any idea why and how can i change it? i looked and tried ini_set but no effect

I want to upload a video but the move_uploaded_file is returning false. The file destination is correct as I'm sure.

Here is the PHP:

if(isset($_FILES['vid'])){
  if($_FILES['vid']['type'] == 'video/mp4'){

    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1023456789";

    $randName = substr(str_shuffle($chars), 0 , 15);

    if(file_exists('data/users/videos/'.$randName.''.$_FILES['vid']['name'])){

    }// end of file exits
    else {
      $des = 'data/users/videos/'.$randName.''.$_FILES['vid']['name'];
      echo move_uploaded_file($_FILES['vid']['tmp_name'],
      $des);

    }
  }// end of checking the file type[video]
}

Here is the page with the upload form:

<?php 
  include("./includes/upload_vid.php");
?>
<html>
 <head>
  <style>
  </style>
 </head>

 <body>
  <form method="post" enctype="multipart/form-data">
   <input type="file" name="vid">
   <input type="submit" name="uploadv" value="Upload">
  </form>

 </body>
</html>

The page with form is in demosite folder. The destination folder is in demosite/data/users/videos.

Upvotes: 1

Views: 991

Answers (1)

fortune
fortune

Reputation: 3372

As php.net

http://php.net/manual/en/ini.list.php

upload_max_filesize "2M" PHP_INI_PERDIR PHP_INI_ALL in PHP <= 4.2.3.

PHP_INI_USER: Entry can be set in user scripts (like with ini_set())
PHP_INI_PERDIR: Entry can be set in php.ini, .htaccess, httpd.conf
PHP_INI_SYSTEM: Entry can be set in php.ini or httpd.conf 

Along with

Need to increase post_max_size as well.

post_max_size integer

Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.

EDIT:

You need to restart Apache so the changes take effect.

This may be useful for you.

Upvotes: 1

Related Questions