
April 30th, 2002, 02:48 PM
|
|
Junior Member
|
|
Join Date: Apr 2002
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Error with ftp_put
This code was working 2 days ago. this script takes an image resizes and makes thumbnails, then ftps the files to a server!
It connects, starts the file upload, but dies. leaving one 0byte file. then i get this error
Warning: ftp_put: PORT command successful. in c:\apache\htdocs\gd\upload.php on line 45
Fatal error: Maximum execution time of 30 seconds exceeded in c:\apache\htdocs\gd\upload.php on line 46
////////////////////////////////////////////////////////////////////////////////////
PHP Code:
<?
$upload_amount='4';
switch($action_id){
case 3:
// Connect to FTP Server!!!!!
$ftp_server = "***********";
$conn_id = ftp_connect("$ftp_server");
$VIN='test';
$login_result = ftp_login($conn_id, "*******", "*******");
// Error Checking the connection
if ((!$conn_id) || (!$login_result)) {
echo "Ftp connection has failed!<br>";
echo "Attempted to connect to ".$ftp_server." for user ".$user."<br>";
die;
} else {
// Begin image resize code!
for($i=0;$i<$upload_amount;$i++){
if (is_uploaded_file($autoImage[$i])) {
$image_size[$i] = GetImageSize($autoImage[$i]);
// Getting size ratio for larger images with a set width of 500 pixels
$new_w[$i] = '500';
$ratio_div1[$i] = $image_size[$i][0] / $new_w[$i];
$new_h[$i] = $image_size[$i][1] / $ratio_div1[$i];
// Rendering Larger Images
$dst_img[$i] = ImageCreate($new_w[$i],$new_h[$i]);
$src_img[$i] = ImageCreateFromjpeg($autoImage[$i]);
ImageCopyResized($dst_img[$i],$src_img[$i],0,0,0,0,$new_w[$i],$new_h[$i],ImageSX($src_img[$i]),ImageSY($src_img[$i]));
$new_img[$i] = Imagejpeg($dst_img[$i],$autoImage_name[$i],80);
// Getting size ratio for thumbnails with a set width of 100 pixels
$th_w[$i] = '100';
$ratio_div2[$i] = $image_size[$i][0] / $th_w[$i];
$th_h[$i] = $image_size[$i][1] / $ratio_div2[$i];
// Rendering thumbnails
$dst_th_img[$i] = ImageCreate($th_w[$i],$th_h[$i]);
$src_th_img[$i] = ImageCreateFromjpeg($autoImage[$i]);
ImageCopyResized($dst_th_img[$i],$src_th_img[$i],0,0,0,0,$th_w[$i],$th_h[$i],ImageSX($src_th_img[$i]),ImageSY($src_th_img[$i]));
$th_name[$i] = "th_".$autoImage_name[$i];
$new_th_img[$i] = Imagejpeg($dst_th_img[$i],$th_name[$i],40);
// Upload Now
if(!$new_img[$i]){echo"<center><b>Upload Failed!</b></center>";
}else{
ftp_chdir($conn_id, "htdocs/carlot");
ftp_mkdir($conn_id, $VIN);
ftp_chdir($conn_id, $VIN);
// FTP UPLOAD HAPPENS HERE
ftp_put($conn_id, $autoImage_name[$i], $autoImage_name[$i], FTP_BINARY);
ftp_put($conn_id, $th_name[$i], $th_name[$i], FTP_BINARY);
ImageDestroy($src_img[$i]);
ImageDestroy($new_th_img[$i]);
}
}
}
}
break;
DEFAULT:
?>
<form method='post' enctype='multipart/form-data' action='<?php echo $PHP_SELF."?action_id=3"; ?>'><input type='hidden' name='VIN' value='<? echo $VIN;?>'><?
for($i=0;$i<$upload_amount;$i++){
$m = $i + 1;
echo"<b>Photo ".$m."</b><br>
<input type='file' name='autoImage[]'><br>";
}
?>
<input type='submit' name='upload' value='Upload Now'></form>
<?
break;
}
?>
|