473,672 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3138
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.*******@gmai l.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.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lBrowserRead");
netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lFileRead");
var x = new XMLHttpRequest( );
x.open("GET", "file:///C:/AUTOEXEC.BAT", true);
x.onreadystatec hange = 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 bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.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
3390
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 LANGUAGE="JavaScript" type="text/javascript" src="$myPageVar$"></SCRIPT> ....where $myPageVar$ is a variable I've declared, and somehow, magically, its value gets put into this directive? The only way I can
1
368
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 field, the ErrorMessage is displayed successfully with the help of validator control, but the page is still being
5
13990
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 language) dll. 2. Write a web page in ASP.NET. 3. Put the dll from 1 into the virtual directory that 2 lives in (the root).
8
11715
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 otherwise) before sending it to the server as it takes a long time to do this operation. I am currently using xmlhttp. Sample code below. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST",'http://xyz.com',true); var vSendXML =...
3
1351
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 control into this Web tool we are building, specifically the InitDir and FileType properties. The end user needs to select a file stored client-side - is this possible using IE6?
6
9502
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 to a link if possible. Thanks, Dinoo
0
1611
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 upload javascript using the below link: http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
2
6641
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 fout = new FileOutputStream(outputFile); ^ import java.io.*;
2
2691
by: sanjuindia2005 | last post by:
How can i read the excel sheet using javascript ?
0
8508
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8428
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8652
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8704
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7484
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4253
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2849
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 we have to send another system
2
2104
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.