Hello, I need to process some data and save it. I am forbidden to save it on my own database - so I will not.
Is there a way to save a file on the user's comptuer (forget about how I can get it back for now)?
saving file on the user's computer
Moderator: General Moderators
-
TheStoryTeller
- Forum Newbie
- Posts: 15
- Joined: Fri May 01, 2009 10:13 am
Re: saving file on the user's computer
How much data you need to save? If it is small amount of data, you can use cookie. You can save a file also just asking the user to download it... you just need to send the correct headers and output the data... the browser will ask the user to save the file and will save it. Then you have to ask the user to upload the file in order to load the data back.
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: saving file on the user's computer
Isnt that what viruses do?TheStoryTeller wrote:Is there a way to save a file on the user's comptuer
-
TheStoryTeller
- Forum Newbie
- Posts: 15
- Joined: Fri May 01, 2009 10:13 am
Re: saving file on the user's computer
ok, both methods sound good, I think I like the first one better. The data i'm collecting is a simple list (probably text file in a certain format or it could be XML) but it's size can be between 5 to 20 KB, depends on the user. is that range of size is "cookie-able"?Darhazer wrote:How much data you need to save? If it is small amount of data, you can use cookie. You can save a file also just asking the user to download it... you just need to send the correct headers and output the data... the browser will ask the user to save the file and will save it. Then you have to ask the user to upload the file in order to load the data back.
and about the headers.. I never really got them down propely.. if your'e aware of any good tutorial/example on the subject (other than the php.net site..) which i'll miss if I simply google it - I would love to know about it.
Thank You.
-
TheStoryTeller
- Forum Newbie
- Posts: 15
- Joined: Fri May 01, 2009 10:13 am
Re: saving file on the user's computer
hmmm.. but I don't want to build a virus.. are you implying that it's impossible? or maybe I need the user's permission?jaoudestudios wrote:Isnt that what viruses do?TheStoryTeller wrote:Is there a way to save a file on the user's comptuer
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: saving file on the user's computer
you will need the users permission, unless you use a cookie as Darhazer suggested, but then you are limited with how much data you can save.
Re: saving file on the user's computer
More than 4 KB is not suitable for cookies, altough some web browsers and/or web server can allow it.
As for the download, I have written such few times, I have no code in front of me (I can send one when I'm in the office, just P.M. me), but generally you need Content-type: application/ocstream, and Content-dispossition: attachment.
I think using this keywords you can find a working example
Also, you may be interested in how much data can flash store in the SharedObject, if flash is suitable for your needs. The last suggestion is going trough ActiveX control - if user permit it, it have access to the filesystem.
And one more think - you can try using a service to save the data on a web host, and set only id in the cookie, or switch the hosting provider, so you can save at the server.
Good luck!
As for the download, I have written such few times, I have no code in front of me (I can send one when I'm in the office, just P.M. me), but generally you need Content-type: application/ocstream, and Content-dispossition: attachment.
I think using this keywords you can find a working example
Also, you may be interested in how much data can flash store in the SharedObject, if flash is suitable for your needs. The last suggestion is going trough ActiveX control - if user permit it, it have access to the filesystem.
And one more think - you can try using a service to save the data on a web host, and set only id in the cookie, or switch the hosting provider, so you can save at the server.
Good luck!