473,508 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read and write local text files

dreamfalcon
20 New Member
Hi!
I need to read and write the content of a text file given by the users.

The idea is to have two options.
Read:
-the user selects a file with a <input type="file">
-using javascript, read the content of the file and process it.

Write:
-build a string and display a "Save as dialog" to save to a text file

I just need it to work in Firefox.
I´m using mootools if it helps.
Can anyone help me?

thx in advance
Feb 15 '08 #1
10 8145
acoder
16,027 Recognized Expert Moderator MVP
JavaScript can't access the local file system and read/write local files. You will need some server-side code to be able to upload the file and then read/write it.
Feb 16 '08 #2
dreamfalcon
20 New Member
That's a bummer :(

But ok, now the question is how to upload using ajax?
I think I've done it in the pass, but I cant remember how.
I have to use a iframe !?

Thx
Feb 19 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Here's one example. It still uses an iframe.
Feb 19 '08 #4
rnd me
427 Recognized Expert Contributor
Hi!
I need to read and write the content of a text file given by the users.

The idea is to have two options.
Read:
-the user selects a file with a <input type="file">
-using javascript, read the content of the file and process it.

Write:
-build a string and display a "Save as dialog" to save to a text file

I just need it to work in Firefox.
I´m using mootools if it helps.
Can anyone help me?

thx in advance
it will be possible in firefox3.
look at the changelog for more information.
Feb 19 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
I need to read and write the content of a text file given by the users.

The idea is to have two options.
Read:
-the user selects a file with a <input type="file">
-using javascript, read the content of the file and process it.

Write:
-build a string and display a "Save as dialog" to save to a text file

I just need it to work in Firefox.
Looking at this again, maybe XUL will help, e.g. see this link.
Feb 19 '08 #6
dreamfalcon
20 New Member
Looking at this again, maybe XUL will help, e.g. see this link.
I already tried, gives as error of permission denied in
"netscape.security.PrivilegeManager.enablePrivileg e("UniversalXPConnect");"
Feb 20 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
I already tried, gives as error of permission denied in
"netscape.security.PrivilegeManager.enablePrivileg e("UniversalXPConnect");"
You may need to change some settings. It works for me (when I allow from the popup warning).
Feb 20 '08 #8
shahjapan
63 New Member
You may need to change some settings. It works for me (when I allow from the popup warning).
you can store anything that u want to store using preferences in firefox.
Feb 26 '08 #9
rnd me
427 Recognized Expert Contributor
here is a save as routine for you: (ff only)


Expand|Select|Wrap|Line Numbers
  1.  
  2. function dataUrlStr(data) {
  3.     return "data:x-application/plainText," + escape(data); 
  4. }
  5. window.open(dataUrlStr("hello world"))
  6.  
  7.  

using an unknown mime causes a save/open prompt.


you will likely need a server echo to read the local files.
in asp3 it would be something like

Expand|Select|Wrap|Line Numbers
  1. response.binaryWrite(request.binaryRead)
Feb 26 '08 #10
rnd me
427 Recognized Expert Contributor
you can store anything that u want to store using preferences in firefox.

what preferences are you referring to? i couldn't find anything, but i would love to be able to save as described.
Feb 26 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

17
10458
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
7
18544
by: Christian Schmitt | last post by:
Hi, I want to write a script that (run from a file on the local HD) reads another local html-file into a variable, then make some changes to it, and then output the result in a way that makes it...
2
9536
by: Alex | last post by:
Yes you can: <html><head><script language="javascript"> SaveToFile('This is a text to save in a file', 'C:\\temp\\test.txt'); alert(read('C:\\temp\\test.txt')); function SaveToFile (text,...
3
18953
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
3
8271
by: eholz1 | last post by:
Hello PHP Group, I am having trouble setting permissions correctly so that the magickwand api (php 5.2) can read and write images. I usually read a file from one directory, create a magickwand...
6
9722
by: 000dreamsound000 | last post by:
Hi I need help with to access a text file over my local network. I need to be able to create,read, write and delete the txt file on a specific machine(s) from any computer over the network. The...
2
5439
by: Kevin Ar18 | last post by:
I posted this on the forum, but nobody seems to know the solution: http://python-forum.org/py/viewtopic.php?t=5230 I have a zip file that is several GB in size, and one of the files inside of it...
4
3190
by: Ross | last post by:
Hello, I am trying to Read and Write to a text file on a web server using Microsoft Visual Basic 2005 Express Edition. So far I have managed to complete my testing with a local text file using...
2
1085
by: Adela Arpitha | last post by:
Hi, i'm using asp.net 1.1 for my project. I have a written a c# code where the user can upload his files through the file upload component which gets uploaded to the specified path in a local...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.