473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stop and Resume Download

162 100+
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.
If you previously downloaded a file before (like a huge web log), and just want to get the remaining portion, do this:

Expand|Select|Wrap|Line Numbers
  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);
  3.  
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.
Mar 2 '08 #1
5 3101
empiresolutions
162 100+
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.
Mar 2 '08 #2
empiresolutions
162 100+
How/When is $_SERVER['HTTP_RANGE'] or $_ENV['HTTP_RANGE'] set? I am working on a resume download script that requires the HTTP_RANGE to be set... but no matter what i do i cant find how/when its set. Thanks.
Mar 5 '08 #3
empiresolutions
162 100+
http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt

This link explains a lot about HTTP_RANGE. It still leaves out two important points...

The server will send this header only for documents for which it will
be able to satisfy the byte range request, e.g. for PDF documents, or
images, which can be partially reloaded if the user interrupts the
page load, and image gets only partially cached.
What types of files satisfy the byte range request? also,

The Request-Range header is simply ignored
by a server that does not support it, and it will send the entire
document as a response.
How do i know if my server supports it?
Mar 5 '08 #4
empiresolutions
162 100+
Still looking for info on this subject. thanks.
Feb 1 '09 #5
Atli
5,058 Expert 4TB
You can obviously not force this upon the client, but if his download manager supports it, it should pass the HTTP_RANGE header to you, specifying which part of the file it wants to download.

Then you would send that range, passing along the Content-Range header, indicating the range you are sending.

I Googled those headers and found a nice example in the comments on the fread manual entry (Search for the poster "Edward Jaramilla").
Feb 1 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: | last post by:
I want send my zip files in my page from inside php. With this I know how many people have download my file and other information. My problem is this, I have this code but it dosn't resume broken...
6
by: JT | last post by:
is it possible to somehow "jump out of" an ASP page that is executed from another page via the Server.Execute method? on the page being executed i have several instances where i need to stop the...
2
by: Shweta | last post by:
Hi, We are trying to buid an application in c++ which will have FTP download and FTP resume download facility.FTP download is working fine but there is a problem with resume download. For...
0
by: Chuck Anderson | last post by:
I am writing a Php script to run on my home PC (Windows) that downloads an Apache access log file and inserts new entries into a database.. The only way I can access these log files is through a...
5
by: juky | last post by:
Hi all, I have 3 running threads chencking for something in my application. Based on that I need to stop some of them safely wait for something else and restart. Sleep is not good in my case...
1
by: Chameleon | last post by:
I want to send a static file, via php to browser with ability to resume download. This is the code: -------------------------------------------- function send_file($file, $offset = 0, $offset2 =...
1
by: yashu | last post by:
hi...can anyone help me,how to upload resume or download resume or project files & download to word files.My front end is vb6.0 and backend is ms access. please help me.
1
by: Alexander Vasilevsky | last post by:
How do you know the server supports resume download or not, if supported send a request to resume? http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas discount
0
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
My program needs to do X when someone 'starts using' their Windows user account, and it should do Y when they 'stop using' their Windows user account. By 'starts using' I mean they log on, unlock...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.