| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 |
Uploading/Posting large files through PHP
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
meout);
$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
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.

Recent comments