Download large file up to 100 MB using php

I make a website for hosting files, such as web hosting (megaupload, rapidshare, mediafire, etc.) using PHP (or tell me if it can be easily implemented in ASP.NET).

The project is almost complete, but the download module is not working properly. I’m Google, but could not find any help, so I thought to ask here if anyone could help.

Whenever I try to upload a file of size in kb, the script runs fine and downloads the file, but when I select a file larger than 1 MB, it gives an error message during upload, can someone help me how can I upload file using HTTP protocols in PHP.

Here is my script to download:

// 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.';  
+2
source share
3 answers

php.ini, :

post_max_size upload_max_filesize

+3
ini_set("memory_limit","2048M");    # 2 GB
set_time_limit(0);          # unlimited transfer time
+1

All Articles