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.
Export file to local desktop (can select folder/directory)
Moderator: General Moderators
-
antoniobanjeras
- Forum Newbie
- Posts: 10
- Joined: Mon Aug 04, 2008 11:13 pm
Re: Export file to local desktop (can select folder/directory)
It's called a "download".
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.
Code: Select all
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");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.
-
antoniobanjeras
- Forum Newbie
- Posts: 10
- Joined: Mon Aug 04, 2008 11:13 pm
Re: Export file to local desktop (can select folder/directory)
tasairis, thanks.
exactly the stuff i've been looking for.
exactly the stuff i've been looking for.