0

I have a php file which generate a file to be downloaded using POST parameters. I already have everything working to resume file downloading (using Range header and everything related).

However, if I pause the download and then try to resume it, the browser does not send POST data in the request. This works fine using GET data instead but I'd like to keep using POST. How could I make this work ?

Notes:

  • The file is generated on the fly and sent to the browser (simply print'ed by php) using the right headers.
  • I cannot save the file somewhere and serve it. It has to be served on the fly.
Lynesth
  • 81
  • 6
  • Downloading a file is nothing more then a http request, since post and get rely on user input, only 1 other option is available. Sessions. But all this depends on browser implementation and there are dozens to consider. – Xorifelse Nov 19 '16 at 07:51
  • @Xorifelse Could you please elaborate your thoughts on sessions ? – Lynesth Nov 19 '16 at 09:30

1 Answers1

0

*sorry for my bad english.

well, lets say that you have database to save the POST params.
then you need to create unique url for the download based on the params.
lets say that the download link is dowload.php <- you send the POST here.

now you need to save the params there, and lets says that you get the unique_id.
after that you redirect the page to the new page(with the unique_id param) that process the download, for example resume_download.php

example download url will be resume_download.php?req=[your_unique_id] or you can use .htaccess to made the url more friendly

this is not guarantee the download will continue, but at least user don't need to re-enter the form.

Atmahadli
  • 687
  • 8
  • 14
  • I could simply send my parameters with GET from the beginning (which isn't really different from what you're proposing, with the added struggle of saving it in a database). I guess there's no way to make that work without using GET. – Lynesth Nov 20 '16 at 01:28
  • I though so, but if your form have tons of input, the get params will not enough to accommodate. – Atmahadli Nov 20 '16 at 03:06