Page 1 of 1
Export file to local desktop (can select folder/directory)
Posted: Tue Oct 14, 2008 11:28 pm
by antoniobanjeras
Hi
Is there a php command to export (or copy) file from server (my server running linux) to local desktop or user can select folder from local computer.
thanks.
Re: Export file to local desktop (can select folder/directory)
Posted: Wed Oct 15, 2008 2:57 am
by requinix
It's called a "download".
Code: Select all
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
Create a new page - this will be specifically for letting users download stuff. Use $_GET or $_POST or whatever and figure out what file to download.
Make sure they're allowed to download it!
Then put that code in the script (remember to set $filename to whatever you want the name of the downloaded file to be) and print out the file contents, perhaps using
readfile. User will get a save/open dialog and they can do what they want.
You cannot force them to download something to a specific place. The best you can do is what I've said: give them the choice of where to save the file, if they want to download it at all.
Re: Export file to local desktop (can select folder/directory)
Posted: Thu Oct 16, 2008 4:54 am
by antoniobanjeras
tasairis, thanks.
exactly the stuff i've been looking for.