By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

FileSystemObject - reading a picture file

P: 3
hi,

i am trying to use the fileSystemObject methods to read a picture file as a text (forcefully), store it in a variable, and then i try writing it back to a file and opening it up with a text editor. I just don't get why they get corrupted:

var ForReading = 1;
var TriStateUni = -2;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newFile = fso.OpenTextFile(localPath, ForReading, false, TriStateUni);
var tempText = newFile.readAll();
newFile.close();
var qqq = fso.CreateTextFile ("C:\\xxxxxxxxx22.txt", true);
qqq.Write (tempText );
qqq.Close();

what i get in the xxxxxxxxxx22.txt file is exactly the head and tail portions of the original .jpg file. and a whole chunk of blanks/empty spaces in the middle.

when i do a tempText.length, the length is the same as the amount of characters in the original .jpg file.

* * *

other than this, is there any other better method in Javascript that i can use to open up any files (not just jpg) as text, ie, like using notepad to do so? and hopefully, cross browser?

i'm doing a project and the aim of having any file in a var is to do encryption on it..

thank you to anybody who can help me....
Jun 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: 1
For security, file reading and writing is not a common feature of browsers, i believe only IE has it, and that still has security limitationes, like only letting the script run if the client says so. And the only way to read/write files is using the FileSystemObject.
Nov 12 '06 #2

Post your reply

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