Stop and Resume Download

  • cesarcesar
  • Novice
  • Novice
  • cesarcesar
  • Posts: 23

Post 3+ Months Ago

I have some scripts that when initiated by a link click will FTP a 1G+ file from a secure server to another server using ftp_get(). Once ftp_get() is complete i then user Content Headers to open a "save as" dialog box. (working good to this point).

Since the files are so large there will be times when a user loses connection or something else that interrupts the download happens. Now what i need is to be able to "finish" the download from the point it was left off.

I have some ideas about how this should be done, but not sure how to code it or if im even going the right direction. My thinking is to -

1. get filesize of trasfering file.
2. check to see if file resides in location being "saved as..".
3. if file does not exist, then download normal.
4. if does exist then, check the server file size against the local file size. if they are different, start the download from the left off point merging the two files some how together on the clients local machine.

I did pluck this out of the ftp_get() php.net page. I think this is uesfully just not complete for what i need.
Quote:
If you previously downloaded a file before (like a huge web log), and just want to get the remaining portion, do this:

Code: [ Select ]
$local_file_size = filesize($local_file_path);
$get_result = ftp_get($conn_id, $local_file_path, $remote_file_path, FTP_BINARY, $local_file_size);
  1. $local_file_size = filesize($local_file_path);
  2. $get_result = ftp_get($conn_id, $local_file_path, $remote_file_path, FTP_BINARY, $local_file_size);
This same code works regardless of wether the local file exists already or not. You should first test to make sure the local file is not bigger than the remote file.
Thanks for all the help in advance.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • cesarcesar
  • Novice
  • Novice
  • cesarcesar
  • Posts: 23

Post 3+ Months Ago

I think the resumepos parameter of ftp_get couple with the startpos parameter of ftp_put should handle this?

I have looked into this but there is so little documentation on the "resumepos" and "startpos" parameters and how they work. I'm not sure how to use.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

The way some downloads go is when the user starts a download, the downloader makes a temporary file in the desktop (or wherever the download destination is) and saves the currently saved stuff in the temp. That way if the connection is lost it would pick up where it has left off using that temporary file.

Firefox downloader does that and you might be able to implement that. I actually don't know how that...
  • cesarcesar
  • Novice
  • Novice
  • cesarcesar
  • Posts: 23

Post 3+ Months Ago

I'm still looking for a way to resume download if anyone has any suggestions. Thanks.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 128 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.