Upload large File upto 100MB using php

10,692

Solution 1

open php.ini, find and edit directives:

post_max_size upload_max_filesize

Solution 2

Here are some previous stack overflow questions that may have the answer you're looking for https://stackoverflow.com/questions/4083100/php-uploading-large-files-fai

upload large files using php, apache

Here's an external site with some good advice http://www.radinks.com/upload/config.php

If users are downloading large files from your site too you may want to direct your web server to offer compressed download. How you do that depends on your webserver and be aware that it may have negative consequences for people using older browsers like IE6.

Solution 3

ini_set("memory_limit","2048M");    # 2 GB
set_time_limit(0);          # unlimited transfer time
Share:
10,692
Mudassar
Author by

Mudassar

Updated on June 15, 2022

Comments

  • Mudassar
    Mudassar almost 2 years

    I am making a file hosting website like web hosting sites (megaupload, rapidshare, mediafire etc.) using PHP (or tell me if its easy to implement in ASP.NET).

    Project is almost complete but uploading module is not working correctly. I Google it but couldn't find any help so thought to ask here if anybody can help.

    Whenever I try to upload a file of size in kb, the script execute well and upload file but when I select a file of size greater than 1MB, it gives error message during upload, can anybody help me how can I upload file using HTTP protocols in PHP.

    Here is my script for upload:

    // Configuration - Your Options
    
    $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); 
    $filename = $_FILES['userfile']['name'];
    $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
     if(!in_array($ext,$allowed_filetypes))
     die('The file you attempted to upload is not allowed.');
     if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
      die('The file you attempted to upload is too large.');
     if(!is_writable($upload_path))
      die('You cannot upload to the specified directory, please CHMOD it to 777.');
     if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
         echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; 
     else
         echo 'Error during uploading.';  
    
  • Lightness Races in Orbit
    Lightness Races in Orbit about 13 years
    @junto: If this is the answer to your question, please click on the tick to "accept" it.