Read and Write local files in a local web browser page with a plugin and javascript
$30-99 USD
Annulé
Publié il y a presque 13 ans
$30-99 USD
Payé lors de la livraison
A simple, small cross-browser plugin to enable the user to write to a local file and read from a local file by clicking buttons. The information to be saved in the file comes from javascript, and when the file is read, the output is to javascript.
## Deliverables
fileio plugin specification:
I think I have researched enough to establish that the requirement of this project is for a plugin.
How it works:
A .htm file is saved locally on a computer (e.g. [login to view URL]). It can have any name, and can be saved in any location.
Saving a file.
* -The file [login to view URL] is opened in a browser. The user is able to click a button on the page, and a string specified in javascript is saved to a file name that is also specified within the javascript in much the same way as a file is downloaded from a web page. Both the file name and file contents need to be dynamic e.g. they might contain a random number generated by the javascript when the user loads the page. The javascript side of this project is complete.
* -If the file name already exists, the user should be asked if they want to overwrite the file. This is not critically important, and for simplicity and future compatibility, the plugin should offer whatever the browser's default action is when downloading a file where the name already exists e.g. downloadedfile(1).txt
Reading a file.
* -On clicking an HTML button (e.g. Browse...) The user of [login to view URL] should also be able to read a local file into a 1 dimensional javascript array where each line in the file is an element in the array and element zero is the full file path. The browse dialog should work in much the same way as attaching a file to an email works.
Notes
* -For security, the plugin should not work from an online page, only a local one. My file is saved at: file:///C:/Users/user/Desktop/[login to view URL] but it should work for a local file with any name, saved in any local folder.
* -I understand that the ability to read and write files to the user's system from within is a security risk, but it adds greatly to the usability of this project.
* -I would like the plugin to work on Windows, Mac, Linux and on Chrome, Firefox, IE and Safari, but I would settle for Windows and Chrome, Firefox and IE.
* -I think the coding elements of the plugin should be relativly straightforward. There is an application called Firebreath where cross browser and OS plugins can be developed. I understand the plugin type is an NPAPI plugin, though that might be different for Internet Explorer.
* -I don't know what format the plugin would have. If it was a single .exe file that could be launched on and OS for any browser, great. If a different file was created for each OS/browser environment, that's not a problem.
* -I would like to examine all source code and know what system the plugin was developed in.
Below is an example of the code contained within [login to view URL] :
<pre>
<html>
<head>
<title>Page</title>
<script type="text/javascript">
function savefile() {
var variable1=[login to view URL]([login to view URL]()*10+1);
var variable2=[login to view URL]([login to view URL]()*10+1);
var savefilename="page"+variable1+".txt";
var savefilecontents="this is the contents of the file. It can be any text, and dynamically generated."+variable2;
//Code communicating with the plugin goes here.
//When the user clicks the Save button the savefile function is called
alert("Saved: "+savefilename);
}
function loadfile() {
var loadfilepath="";
var loadfilecontents="";
//Code communicating with the plugin goes here.
//File path and file contents are saved to a 1 dimensional array where element [0] is the file path and the remaining elements are the lines of the file, or two separate variables as shown here.
alert("Loaded: "+loadfilepath+" containing: "+loadfilecontents);
}
</script>
</head>
<body>
<button onclick="savefile();">Save</button>
<br />
<input type="file" onclick="loadfile();"></input>
</body>
</html>
</pre>