473,419 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Can We read client side files using javascript

Can We read client side files using javascript? not only text files
Jun 27 '08 #1
4 3123
parveen wrote:
Can We read client side files using javascript? not only text files
Yes, with XHR, but only from a file: URI to a file: URI, or with a
privileged script. In MSIE 7+ you are required to use the ActiveXObject
object instead of XMLHttpRequest for that.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #2
parveen <k.*******@gmail.comwrites:
Can We read client side files using javascript? not only text files
Yes. No. Some. Depending on what you mean.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #3
Thomas 'PointedEars' Lahn wrote:
parveen wrote:
>Can We read client side files using javascript? not only text files

Yes, with XHR, but only from a file: URI to a file: URI, or with a
privileged script. In MSIE 7+ you are required to use the ActiveXObject
object instead of XMLHttpRequest for that.
Just in case anyone is interested, the following works from a `http:' URI in
Fx 2.0.0.13 if the supporting feature is enabled[1]:

try
{
netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege ("UniversalFileRead");
var x = new XMLHttpRequest();
x.open("GET", "file:///C:/AUTOEXEC.BAT", true);
x.onreadystatechange = function() {
if (x.readyState == 4) window.alert(x.responseText);
};
x.send(null);
}
catch (e)
{
e
}

It is important that both privileges are requested and granted. Firebug
then still displays

| Security Error: Content at http://... may not load or link to
| file:///C:/AUTOEXEC.BAT.

but the content of the file is displayed anyway. Code running out of the
sandbox does not have to request the privileges though, so be careful with
what extensions you install :)
PointedEars
___________
[1]
http://developer.mozilla.org/en/docs...d_Signing_Code
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #4
The Magpie wrote:
Thomas 'PointedEars' Lahn wrote:
>parveen wrote:
>>Can We read client side files using javascript? not only text files
Yes, with XHR, but only from a file: URI to a file: URI, or with a
privileged script. In MSIE 7+ you are required to use the ActiveXObject
object instead of XMLHttpRequest for that.
You can with XMLHttpRequest, Pointed. It doesn't really care what type
the files are as long as they are text-content (not binary).
It would appear you are replying to something I have not written.
PointedEars
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Greg | last post by:
I'm trying to simulate server-side includes on the client-side by using JavaScript. My main problem is this: is there a way to somehow pass a variable into a directive like this: <SCRIPT...
1
by: | last post by:
Dear Justin, Thanks for your reply! Let me explain you my concern in detail.... I have a login field which I am validating using RequiredValidator control. Now when a user omits this...
5
by: steve_barker333 | last post by:
Hi guys! I found a great article a while ago about how to write client side C#. Sadly, I can't find it again now, but here's the jist of what I learnt to do: 1. Write a C# (or any .NET...
8
by: vnarayana | last post by:
Need to transfer large data (Appox 5MB in the form of XML & HTML) from Internet Explorer to Web sphere application server. Want to know if there is anyway I can compress data (JavaScript or...
3
by: KathyMarriage | last post by:
Hello In days gone by I was a VB programmer but currently tasked to find some answers for a ASP guy. Basically I am wanting to incorporate some of the functionality of the Common Dialog...
6
by: dinoo | last post by:
Hi, I would appreciate if some one could help me out. I have to read a client side ini file in Aspx page and use that data in server side processing. Can any one help me out here? Please refer...
0
by: pbd22 | last post by:
Hi. I am having a really tough time here and would appreciate some help. i am using an iFrame to pass a url string of files to upload to server. on the client i have created a multiple...
2
by: asenthil | last post by:
i'm trying to read and write files using java... some errors occurs when i'm trying this code.. Error in java: Cannot find symbol location: class java.io.FileOutputStream FileOutputStream...
2
by: sanjuindia2005 | last post by:
How can i read the excel sheet using javascript ?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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,...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.