开发者

With JavaScript is it possible to Read/Write from/to a file on the server

I have a series of JSON Objects I want to save locally on my server. I am attempting to avoid any server-side script like PHP as required per demand of whats being built. I know its a security risk, but that in this case is not a particular worry. So that s开发者_如何学运维aid is it possible to actually write to a file and or get its contents via javascript with or without the help of a lib such as jquery?

I should mention I am attempting to avoid ActiveX as I know this is an IE only feature and the software we are developing is planned to be Cross Browser supported


So that said is it possible to actually write to a file and or get its contents via javascript with or without the help of a lib such as jquery?

Nope. You will need something running on server side that can receive your JavaScript input and write it to the server.

Internet Explorer's proprietary file writing functionality is for writing local (client-side) files only.


You can read a file using ajax, but without a server side language you cannot write a file to the server.

https://developer.mozilla.org/en/ajax


No. Javascript runs on the client. You need server-side code to access the server's file system.


Client-side JavaScript can only send data to a server, there's no way for it to tell the server what to do with the data.

To save data to a file or db on a server, you'll require a server-side script of some sort (could be server-side JS with Node.js). If all you need is persistent data, you could store some JSON strings in localStorage or in cookies as needed. They wouldn't be shareable that way though.


Yes, you can use AJAX requests in JavaScript without using jQuery. However, jQuery will save you an ungodly amount of time and cross-browser testing.

But, as others have already said, you can't write server files without server code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜