Web Hosting Talk







View Full Version : Too many uploads (ftp_put)


kgp43
06-24-2005, 04:46 PM
Hi,

It seems ftp_put cant handle anymore uploads (~1800 per day, 4.5MB avg filesize (some about 50MB)).

How do I raise the limit to something like 10.000 uploads per day (avg 15MB per file)?

kgp43
06-25-2005, 03:10 AM
any suggestions what to do?

the main server is a Dual xeon with 2GB RAM while the fileservers are P4 2.8 with 2GB ram aswell.

Burhan
06-25-2005, 08:27 AM
What error are you getting?

EXOWorks
06-25-2005, 08:38 AM
Are you sure it's not related to the FTP server on fileserver??

kgp43
06-25-2005, 09:19 AM
I receive no errors at all.

Can upload file below 500KB without problems (95%), but on bigger files (+20MB) it only success a few times.
Guess I'm getting 20-30 uploads of files above 30MB per day and another 1700 below 4MB (avg size = 4.2MB).

Have tried everything possible on the server (during the last 3 weeks), but keep getting the same "error".

You can try my test uploader:
http://www.savefile.com/filehost/test.php

code:
<?
//Get time, 3600 seconds (10h) (60MB at 10Kb/sec)
set_time_limit(36000);

//Display all errors
ini_set('display_errors', true);

//Error handling, 0=off 1=on
error_reporting(1);

/*
echo $_FILES['upld_file']['size']." Bytes";
exit();
*/

//Check if any file is submitted
if (!$_FILES['upld_file']['name']) {

echo "<font color=red>No file selected</font>";
exit();
}

//Post filesize
echo "Filesize: ".$_FILES['upld_file']['size']." Bytes (not uploaded yet)<br />";


//Get file name
$file_name = $_FILES['upld_file']['name'];

//Get the file extention
$file_type = $_FILES['upld_file']['name'];
$file_type = pathinfo($file_type);
$file_type = strtolower($file_type['extension']);

//FTP server info
$server_ip = "xx.xxx.xxx.xxx";
$server_ftp_username = "username";
$server_ftp_password = "password";

//Open the FTP connection
$conn_id = ftp_connect($server_ip);
$login_result = ftp_login($conn_id, $server_ftp_username, $server_ftp_password);

// turn passive mode on
ftp_pasv($conn_id, true);

//Check if FTP connection is open
if ($login_result == false) {
echo "<font color=red>Not able to connect to FTP (FS01)<br />
Please contact the webmaster, (<a href='http://www.savefile.com/forums'>Support Forums</a>)</font>";
exit();
}

//Get destinations
$to_file = "testuploads/".$file_name;
$from_file = $_FILES['upld_file']['tmp_name'];

//Open/read file for ftp_fput
$from_file_fp = fopen($from_file, 'r');

//ascii filetypes
$ascii_filetypes = array('htm', 'html', 'shtml', 'cnf', 'css', 'forward', 'map', 'pwd', 'txt', 'grp', 'ctl', 'nfo');

if (in_array($file_type, $ascii_filetypes)) {

//Upload the file to the fileserver using BINARY mode
$ftp_upload = ftp_fput ($conn_id, $to_file, $from_file_fp, FTP_ASCII);

echo "mode: FTP_ASCII <br />
--------------------------------------------<br />
<b>STATUS:</b><br />
--------------------------------------------<br />
<br />";
}else{

//Upload the file to the fileserver using ASCII mode
$ftp_upload = ftp_fput ($conn_id, $to_file, $from_file_fp, FTP_BINARY);

echo "mode: FTP_BINARY <br />
--------------------------------------------<br />
<b>STATUS:</b><br />
--------------------------------------------<br />
<br />";
}

//Check if upload went okay
if($ftp_upload == true) {

//Get filesize in MB
$file_size = $_FILES['upld_file']['size']/1024;
$file_size = round($file_size,2);

echo "SUCCESS <br />
<br />
Filesize: $file_size KB<br />
<br />
(this is only a test upload)";

}else{

//Post error
echo "<font color=red>Error uploading your file (FTP error)<br /></font>";

// File was not uploaded!
switch ($_FILES['upld_file']['error']) // http://www.php.net/manual/en/features.file-upload.errors.php
{

case 1:
echo "<font color=red>The uploaded file exceeds the upload_max_filesize directive in php.ini</font>";
break;

case 2:
echo "<font color=red>The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form</font>";
break;

case 3:
echo "<font color=red>The uploaded file was only partially uploaded</font>";
break;

case 4:
echo "<font color=red>No file was uploaded</font>";
break;

case 6:
echo "<font color=red>Missing a temporary folder</font>";
break;
}
}

//Close the FTP connection
$ftp_close = ftp_close($conn_id);
fclose($fp);

if (!$ftp_close) {

echo "<font color=red>Error closing the FTP connection<br />
Please contact the webmaster, (<a href='http://www.savefile.com/forums'>Support Forums</a>)</font>";
exit();
}
?>

kgp43
06-25-2005, 09:22 AM
If I "activate" the code below, then it post the correct filesize of all uploads, thats why im positive its a FTP problem.

/*
echo $_FILES['upld_file']['size']." Bytes";
exit();
*/

kgp43
06-26-2005, 12:24 PM
Any suggestions?

How can a site like putfile handling all those uploads while my 'small" one cant even handle 1/10 ?