If there are some scripts that save some data to a file, how do we let the user choose where to save it?
On the server or their own PC?
Your question is VERY vague.
I mean on their own PC.
You can only link to that file. You either provide a hyperlink in your page or redirect them using either the header() or outputting a redirect in a html head element.
When the browser requests a download of that file from the server it will automatically prompt the user to save it where they want. Anything text based will nearly always be displayed directly in the browser instead.
Thank you, it worked
Unfortunately the file I’m working with is a .csv, isn’t there any way not to make the browser display it?
You might be able to use the force download header to force it to save it. I’m not sure since i’ve only ever read about it but google should turn something up.
You also might be able to play a trick using header to convince the browser that the content-type isn’t text based. Again I’m entering unchartered territory here so you’ll need to check out google.
Ok I’ll check it out, thank you very much