Re: implementing downloads with php?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Apr 2, 2015, at 6:33 PM, Sean Greenslade wrote:

On Thu, Apr 02, 2015 at 05:58:49PM -0700, Jeffry Killen wrote:
When a web page or a resource like an image or javascript file, or css file "downloads" it is rendered in the browser. It does not appear as a separate file written to the users system. What I am looking for is what might be
described
as the opposite of uploading a file.

Thanks for responses
JK

My suspicion was correct; you're looking to tell the browser that this
is a file to save rather than a file to display. This is accomplished
with headers, which the browser interprets as hints (not commands, as it
is free to ignore them) for what to do with a given page.

A quick google turned up this result:

http://stackoverflow.com/questions/8485886/force-file-download-with-php-using-header

See if that helps.

--Sean

Thank you for the link, I am getting an idea of what is going on here, even though I don't
know that the posters problem was solved.

So, if I understand the basics,

a bunch of headers are sent and then the file is read. But I don't see a print or echo statement
in any of the code in the related posts.

I have read a file as a string, sent a Content-Type header and then used a print statement to send the file contents for an async request: in cases where css or javascript is requested after a page
loads. The output is sent to the browser.

But this situation appears different. The file content is sent to the browser but the browser writes
it directly to a separate file (?)

JK

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux