Need help in uploading videos of big size files

Discussion in 'PHP' started by aleale, Jan 28, 2012.

  1. #1
    When i am uploading under 2 MB file, it is successfully uploaded but when i am trying to upload bigger file then its showing failed to upload issue... my code is following....please help me to get out of this situation...

    
    <?php
    function UploadOne($fname)
    {
    $uploaddir = 'uploadedfiles/';
    if (is_uploaded_file($fname['tmp_name']))
    {
    	
    	$filname = basename($fname['name']);
    	
    	$uploadfile = $uploaddir . basename($fname['name']);
    	if (move_uploaded_file ($fname['tmp_name'], $uploadfile))
    		$res = "File " . $filname . "was successfully uploaded and stored. Upload More<br>";
    		
    					include ('../config.php');
    					mysql_query("INSERT INTO videos (id, path, name, title, content)
    					VALUES ('$_POST[id]', 'url/$filname', '$_POST[date]', '$_POST[title]' , '$_POST[content]')");
    					$data = mysql_query('SELECT * FROM videos ORDER BY id DESC LIMIT 1');
    $info = mysql_fetch_array($data);
    		
    		$res = "<strong>$info[title]</strong>," . "\n Sucessfully Uploaded. \n Upload more".  "<br>" . "<a href='../videos.php'>View Videos</a>";
    		}	
    else
    $res = "File ".$fname['name']." failed to upload.";
    return ($res);
    }
    ?>
    
    Code (markup):
    Thanks in advance...
     
    aleale, Jan 28, 2012 IP
  2. anisbd

    anisbd Active Member

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    83
    #2
    By default, PHP allow a maximum file upload of 2MB. You can increase the limit when necessary.

    Two PHP configuration options control the maximum upload size: upload_max_filesize and post_max_size.
    Both can be set to, say, “10M” for 10 megabyte file sizes.

    Remember, PHP scripts normally time-out after 30 seconds, but a 10MB file would take at least 3 minutes to upload on a healthy broadband connection.
    So you need to set PHP’s max_input_time and max_execution_time to something like 300 (5 minutes specified in seconds).

    You can set these options 3 way -
    1. Set in your server’s php.ini configuration file so that they apply to all your applications.
      
      upload_max_filesize = 10M
      post_max_size = 10M
      max_input_time = 300
      max_execution_time = 300
      
      PHP:
    2. Set in your code.
      
      ini_set('upload_max_filesize', '10M');  
      ini_set('post_max_size', '10M');  
      ini_set('max_input_time', 300);  
      ini_set('max_execution_time', 300);
      
      PHP:
    3. If you’re using Apache, you can configure the settings in your application’s .htaccess file
      
      php_value upload_max_filesize 10M
      php_value post_max_size 10M
      php_value max_input_time 300
      php_value max_execution_time 300
      
      PHP:
     
    anisbd, Jan 28, 2012 IP
  3. aleale

    aleale Well-Known Member

    Messages:
    1,453
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #3
    This seems very helpful information, but there is one confusion... where to find the php.ini file on the server. i am using window hosting for the website and using IIS server...
     
    Last edited: Jan 28, 2012
    aleale, Jan 28, 2012 IP
  4. anisbd

    anisbd Active Member

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    83
    #4
    These php.ini file may be in PHP folder or WINDOWS folder. I am not sure
     
    anisbd, Jan 29, 2012 IP