tags:

views:

102

answers:

2

Can Ajax be used to manipulate client-side files? If so, how?

+1  A: 

No, ajax (=javascript) is sandboxed, it cannot access anything on the computer where the browser is running except the browser. Imagine what would happen if you would surf on the web and suddenly the file C:\boot.ini is deleted :/

soulmerge
I don't see why anyone would have downvoted it.
zneak
@zneak: the irritating part is that people don't explain their downvotes.
Andy E
I down-voted it for not being useful. Many efforts are being made to allow browser-based Javascript apps to have closer connections to the client, with Facebook's latest photo-browsing plug-in being a great example. Answering this question with a simple "no", saying "omg what if `C:\boot.ini` were deleted??" isn't helpful -- of course the browser shouldn't be able to take the system down, but that's the browser maker's responsibility, not the Javascript programmer's. Javascript-based plug-in architectures exist for a reason: to answer "yes" to questions like this.
Ryan Prior
A: 

You can use javascript to do client-side file management if you have special permission from the browser (or other javascript-executing agent) to do so. One good way to get that is to have your script installed as part of a plug-in for Firefox or Chrome, using a toolkit such as Greasemonkey.

So, the answer is "yes, but ask for permission first!"

Ryan Prior
The fact of the matter is that very few users would trust a web site that *wants* to read or write to/from the local file system. And why should they? Asking for permissions doesn't mean that you will get them and probably 95% of the time you won't.
Andy E
That sounds right for the majority of web users, who will pass by anything which requires them to install an extension. However, for a business client, developing a browser extension to allow better desktop integration could be perfectly acceptable.
Ryan Prior