Recommend this page to a friend! | Stumble It! | Bookmark in del.icio.us |
All requests | > | Create a download page | > | Request new recommendation | > | Featured requests | > | No recommendations | ||
by Michel PIERRE - 11 months ago (2015-02-22) download
+1 | I would like to send requested files to user and know when the process ends. |
17. by Amit Gaur - 11 months ago (2015-03-04) Reply
You need to use cookies. first read download.zip and write to the browser after that set cookies. in the last next page check the cookies
18. by Michel PIERRE - 11 months ago (2015-03-18) in reply to comment 17 by Amit Gaur Comment
Ok guys. Thank's for your suggestions. Sorry to be late, but I was a little bit busy the past days. I thnk that AJAX may be the best way to achieve this, and I'm going to explore thist. As it's not a primary goal, it will take me some time to work on it. I'm using Wampser 2.5(x86) on Windows 7x64 with Apache2.4.12, PHP 5.6.6, MySql5.6.23 and I can't understand why x-sendfile (mod_xsendfile-1.0-P1) dosn't work. I recieve an error message: "The requested URL /php/telecharger_chorale.php was not found on this server." Once again Thank's for your help. Best regards, Michel
9. by Sergey Shuchkin - 11 months ago (2015-03-03) Reply
<iframe src="download.zip" onload="fileLoadedScript()" width="0" height="0"></iframe>
11. by Manuel Lemos - 11 months ago (2015-03-03) in reply to comment 9 by Sergey Shuchkin Comment
Interesting and simple. I wonder if the onload event works well on all browsers for iframes.
If it does, all you need to do is to make that fileLoadedScript() function send an AJAX request back to the server, so the PHP side becomes aware that the download was completed successfully.
In that case it would not be hard to make a simple PHP class that implements that.
12. by Dmitry M. Merkushin - 11 months ago (2015-03-03) in reply to comment 9 by Sergey Shuchkin Comment
What if user closes tab/window after download has started?
13. by Manuel Lemos - 11 months ago (2015-03-03) in reply to comment 12 by Dmitry M. Merkushin Comment
In that case it would not be possible to know if the download ended successfully.
The page could have one of those prompts to ask the user if he really wants to close the page before ending the download, but I guess that would not prevent the page to be closed.
The page could even try to notify the server that the page was closed before ending the download.
14. by Dmitry M. Merkushin - 11 months ago (2015-03-03) in reply to comment 13 by Manuel Lemos Comment
Yeah, right. So this method doesn't solve problem.
But we can use our web-server for this purpose (ngx_http_echo_module for nginx).
For client-side we can use standard php's download progress (session.upload-progress). But this method work only for local files.
15. by Dmitry M. Merkushin - 11 months ago (2015-03-03) in reply to comment 14 by Dmitry M. Merkushin Comment
Sorry, mistake with download/upload :)
16. by Manuel Lemos - 11 months ago (2015-03-03) in reply to comment 14 by Dmitry M. Merkushin Comment
Yes, there may be no perfect solution. Still an imperfect solution may still be useful for the original poster if he cannot use a Web server that provides any kind of information about the files served for downloads.
6. by Gerry Danen - 11 months ago (2015-03-03) Reply
A full explanation of the exact requirements (not what is not working) would be helpful.
What kind of files? How large?
7. by Manuel Lemos - 11 months ago (2015-03-03) in reply to comment 6 by Gerry Danen Comment
He wants a way to know if a file was successfully downloaded by the the user.
Since it seems to not be possible to determine that from the PHP server side just by itself, it may be possible using AJAX requests to start the download and save it to some file of choice of the user and then send an AJAX request back to the server when the download is finished.
This is the theory for a possible solution that I described in comments below. I never seen a package that does that. Maybe somebody skilled could develop an innovative package that does that.
8. by Gerry Danen - 11 months ago (2015-03-03) in reply to comment 7 by Manuel Lemos Comment
Thanks, Manuel. Good explanation.
I don't think the server could know the outcome of a download, unless there is some protocol I am not aware of.
Does your server know if a PHP (or JS) package downloads ok? If it does not, I just download again.
This would be great for 2-way communication and potential grabbing files or responses from the client. Would this not be a huge security breach?
10. by Manuel Lemos - 11 months ago (2015-03-03) in reply to comment 8 by Gerry Danen Comment
Yes, you can serve on the download page with some JavaScript that could send AJAX requests back to the server when the download is done. Since it was your server that generated the download page, I do not see a security breach there unless I am missing your point.
1. by Manuel Lemos - 11 months ago (2015-02-25) Reply
There are many classes for serving files for download. Do you have more specific requirements?
For instance do you want to protect the download pages, so you control the users that can download the files?
2. by Michel PIERRE - 11 months ago (2015-03-02) in reply to comment 1 by Manuel Lemos Comment
Hola Manuel, Thanks for your interest. Here is my problem: I'm hosting a website for choral singers. I used to use mod_xsendfile.so in my php download script. A few months ago, this stop working and the page returns: "Not Found The requested URL /php/telecharger_chorale.php was not found on this server." 1) Anyhow, with or without xsendfile I can't know if the download was successfull. 2) I'ld like to know if ther's any other way to download (quickly) big files. Bye, Michel
3. by Manuel Lemos - 11 months ago (2015-03-02) in reply to comment 2 by Michel PIERRE Comment
I don't think it is possible to know for sure if a download is successful at least from the server side.
Usually PHP passes the data to the Web server buffer and from then on PHP may exit the request and the file was not even fully downloaded by the browser.
What you may be able to do is to use AJAX requests on the browser side. I am not sure if it is possible for JavaScript to tell the user to save a file downloaded using AJAX, but at least you may have information of how much was downloaded until it ends. If that works, it could be a nice idea for an innovative package if somebody capable could develop it.
As for serving large files, you can use the PHP function fpassthru. It serves an opened file to the browser until it reaches the end of the file.
Again the file data goes to the Web server buffer, so you never know if the file was fully downloaded by the browser or not.
4. by Michel PIERRE - 11 months ago (2015-03-02) in reply to comment 3 by Manuel Lemos Comment
You're right. There's no way to know.
I gonna try some AJAX classes I've downloded and give a look to the PHP function fpassthru.
Best regards, Michel
5. by Manuel Lemos - 11 months ago (2015-03-03) in reply to comment 4 by Michel PIERRE Comment
OK, this request is going to become featured to give other authors an idea to develop a package that can do what you need generating JavaScript to perform AJAX requests to download the file and report to the server when the download ended.
Recommend package | |
|