Uploading/Posting large files through PHP

  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.
  • : Function ereg() is deprecated in /home/bulahema/public_html/old/includes/file.inc on line 645.

To upload/post large files through PHP, there are 2 methods. One is by setting the directives in php.ini file or using ini_set or set in .htaccess, and the other one is to use PHP's built-in FTP functionality.

1. Set in php.ini or through ini_set:

upload_max_filesize = 30M
post_max_filesize = 32M
max_input_time = 1800
max_execution_time = 1800

Someone said that you also need to set:

memory_limit = 96M

In .htaccess, set

php_value max_execution_time 600
php_value upload_max_filesize 501M
php_value post_max_size 501M

*WARNING* Use only one of the three ways. Do NOT use all or two of them or else it won't work. 

 

2. Use the following script:

<?php
$ftp_server = "yourftpserver";
$ftp_user = "youruser";
$ftp_pass = "yourpass";
$port = 21;
$timeout = 86400; //in seconds -- i just set to a whopping 2 days lol
$uploadFileName = "myFile.someExt";

$file = $_POST["myFile"];

if ($conn = ftp_connect($ftp_server)) {
   if (ftp_login($conn,$ftp_user,$ftp_pass)) {
      ftp_set_option($conn,FTP_TIMEOUT_SEC,$ti

meout);
      ftp_pasv($conn,true);
      $ret = ftp_nb_put($conn,$uploadFileName,$file,FTP_BINARY);
      while ($ret == FTP_MOREDATA) {
         $ret = ftp_nb_continue($conn);
      }
   }
}
if ($ret != FTP_FINISHED) {
   echo "There was an error uploading the file...";
   exit;
}
echo("File uploaded successfully!");
?>

Where $file is relative to your where this file is. So let's say your file is myfile.txt, then put that file in the same directory as the script, and $file="myfile.txt" and it should work fine.