Re: implementing downloads with php?

From: Date: Fri, 03 Apr 2015 02:01:59 +0000
Subject: Re: implementing downloads with php?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-324758@lists.php.net to get a copy of this message
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

« previous php.general (#324758) next »