max_execution_time 300
max_input_time 600
post_max_size 100M
So... if those are seconds for the first two variables... then I know for sure my ftp_post returns false way under 300 sec = 5min
I am stuck and really frustrated... could someone tell me what else should I check in my server settings, or fix with my code? Any help will be geatly appreciated... I'll even mention your name in the file header once this works
Here's the code:
Code: Select all
if (!empty($_POST["action"]) && !empty($_POST["password"]) && !empty($_FILES["file1"]["name"])) {
$login = "customer";
$password = $_POST["password"];
function putFiles ($login,$password) {
$fileNames = array($_FILES["file1"]["name"], $_FILES["file2"]["name"], $_FILES["file3"]["name"], $_FILES["file4"]["name"], $_FILES["file5"]["name"]);
$tempNames = array($_FILES["file1"]["tmp_name"], $_FILES["file2"]["tmp_name"], $_FILES["file3"]["tmp_name"], $_FILES["file4"]["tmp_name"], $_FILES["file5"]["tmp_name"]);
$fileSizes = array();
$fileExtensions = array();
//Initialize sizes of the files
for ($i=0; $i<5; $i++) { //
$fileSizes[$i] = filesize($tempNames[$i]);
}
//Initialize array of file extensions
for ($i=0; $i<5; $i++) {
$ext = explode(".", $fileNames[$i]);
$fileExtensions[$i] = $ext[count($ext) - 1];
}
$MAX_FILE_SIZE = 100000 * 1024; // No files larger than 100 MB
$backstr = "<br><a href=\"index.php\">BACK</a>";
// An array with file extensions that are prohibited
$allExt = array("exe", "bat");
//Check if no files exceed the sizelimit
for ($i=0; $i<5; $i++) {
if ($fileSizes[$i] > $MAX_FILE_SIZE) {
die("File . $i .'s size exceeds $MAX_FILE_SIZE bytes.$backstr <br/>");
}
}
// Go thru all the files submitted
for ($i=0; $i<5; $i++) {
//Connect to FTP
$ftp_id = ftp_connect("ftp.totlpg.com");
$ftp_login = ftp_login($ftp_id,$login,$password);
if (!$ftp_login) {
ftp_quit($ftp_id);
die("Connection failed, check your login and password.$backstr <br/>");
}
//If file was submitted
if (!empty($fileNames[$i])) {
//Check is extension is not prohibited
if (!in_array(strtolower($fileExtensions[$i]), $allExt)) {
if (ftp_put($ftp_id,$fileNames[$i],$tempNames[$i],FTP_BINARY)) {
echo ("Uploading " . $fileNames[$i] . " was <FONT COLOR=\"red\">successful</font>.");
ftp_quit($ftp_id);
}
//Check if upload succeded
else {
ftp_quit($ftp_id);
echo("<FONT COLOR=\"RED\">Upload failed for file " . ($i+1) . ". It is possible that a file with that name already exists on our server, please click BACK, change the name and try again.</font>" . $backstr ."<br/>");
}
}
else {
ftp_quit($ftp_id);
die ("ERROR - File " . ($i+1) . "'s extension is not allowed!" . $backstr . "<br/>");
}
}
}
}
putFiles($login,$password);
}