Page 1 of 1

Uploading takes forever / times out even with smallish files

Posted: Mon Jan 19, 2009 8:04 am
by mattpointblank
Hi everyone,

I have an upload script that only exists locally (it's not meant for public access). When it's done resizing the uploaded content, it moves the files to the external website via FTP.

When I upload a file that's, say, 800kb, the script takes a minute or two to process, eventually either timing out, or just finishing, but leaving me with a 0 byte file uploaded to the webhost. I tried increasing the timeout using set_time_limit() but it still doesn't make much difference.

This is the code I'm using (cut down for legibility):

Code: Select all

 
set_time_limit(360);
$ftp_server = "###";
$ftp_user_name = "###";
$ftp_user_pass =  "###";
 
// set up basic connection
$conn_id = ftp_connect($ftp_server); 
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
 
// check the image is valid, then move it to local folder
 
       include('imageresize.php');
        $image = new SimpleImage();
        $image->load('_img\pictureGallery\\'.$filename); // load the file we just uploaded
 
        $image->resizeToWidth(500);
        $image->save('_img\pictureGallery\full_'.$filename);
 
        $image->resizeToWidth(86);
        $image->save('_img\pictureGallery\thumb_'.$filename);
    
    $thumbfile = "_img/pictureGallery/thumb_$filename";
    $fullfile = "_img/pictureGallery/full_$filename";
    $upload  = ftp_put($conn_id, "htdocs/_img/pictureGallery/thumb_$filename", $thumbfile, FTP_BINARY);
    $upload2 = ftp_put($conn_id, "htdocs/_img/pictureGallery/full_$filename", $fullfile, FTP_BINARY);
 
 
The images are being created fine locally, it's just the FTP process. There's no errors, the file locations are both correct and the remote folder has 777 permissions. The thumbnail file (2kb locally) uploads fine but the fullsize one (22kb) doesn't load.

Anything obvious here?

Cheers
Matt

Re: Uploading takes forever / times out even with smallish files

Posted: Mon Jan 19, 2009 11:09 am
by Burrito
try breaking your process apart into segments (upload file, then upload file with image resize, copy a file using ftp (not the file you just uploaded) to your ftp server...etc).

also try using an ftp client to upload a file to see if there's somethign going on with your ftp server.

Re: Uploading takes forever / times out even with smallish files

Posted: Mon Jan 19, 2009 11:14 am
by mattpointblank
I've used the FTP server using another program, works fine.

How do you mean, into segments? Like, that's basically what it's doing now. All of these steps need to happen simultaneously (the image details are being added to a remote database, so the image needs to be uploaded at the same time) - how can I break them apart more?

Re: Uploading takes forever / times out even with smallish files

Posted: Mon Jan 19, 2009 5:52 pm
by Burrito
what I mean by breaking it into segments is
1) upload the file (make sure that works ok)
2) resize the image (make sure that works ok)
3) upload a file (not the one just uploaded) to your ftp site (make sure that works ok)
4) piece them together and try the whole lot

find out where your breaking point is then you only need to worry about that as the issue.