Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Stop and Resume Download
Old 03-02-2008, 03:03 PM Stop and Resume Download
Extreme Talker

Posts: 196
Trades: 0
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:
$local_file_size = filesize($local_file_path);
$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.
empiresolutions is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-02-2008, 03:50 PM Re: Stop and Resume Download
Extreme Talker

Posts: 196
Trades: 0
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.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 02-01-2009, 05:51 PM Re: Stop and Resume Download
Extreme Talker

Posts: 196
Trades: 0
I'm still looking for a way to resume download if anyone has any suggestions. Thanks.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 02-04-2009, 12:29 PM Re: Stop and Resume Download
spyderwebtech's Avatar
Skilled Talker

Posts: 51
Trades: 0
You could always try to use the CURL library which as the ability to resume a download. Here is the untested base code you could use

Code:
<?php
$local_file = "filename";
$local_fize_size = filesize($local_file);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://site.com/filename1.zip');
curl_setopt( $ch, CURLOPT_RESUME_FROM, $local_file_size );
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
 $result1 = curl_exec($ch);

file_put_contents($local_file, $result1, FILE_APPEND|FILE_BINARY);

curl_close($ch);
?>
This should work
spyderwebtech is offline
Reply With Quote
View Public Profile
 
Old 02-04-2009, 05:14 PM Re: Stop and Resume Download
Extreme Talker

Posts: 196
Trades: 0
thanks much i will give it a try and respond with my result.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 02-04-2009, 06:17 PM Re: Stop and Resume Download
Extreme Talker

Posts: 204
Trades: 0
I'd be interested in hearing your results. I think spyderwebtech suggested a good solution.
__________________

Please login or register to view this content. Registration is FREE
payment proof is offline
Reply With Quote
View Public Profile Visit payment proof's homepage!
 
Reply     « Reply to Stop and Resume Download
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30213 seconds with 12 queries