content top

Access client side files using browser

Is it possible to access files in the client side using a web application/browser ?

Answer :

Yes. It is possible. But only on certain conditions.

Download sample Code here

1) The below code works only in IE.

2) You need to change your security settings in IE to Low.

Select Tools -> Internet Options in IE menu Bar

Select Security  tab. Select Internet and click Custom Level

Reset custom settings to  “Low”

security-settings-ie

How you can Open/Create/Write files in client system using browser ?

For doing this task, you can use Scripting.FileSystemObject

To create a file in the client side, you can use the following code

var fso = new ActiveXObject(”Scripting.FileSystemObject”);
var fileName = “C:\\robin.txt”;
function createFile()
{

var fileObj = fso.CreateTextFile(fileName, true)
fileObj.close();

alert(”A file is created in client side. “+ fileName);

}

Following is set of methods which is supported by FileSystem Object

BuildPath()
CopyFile()
CopyFolder()
CreateFolder()
CreateTextFile()
DeleteFile()
DeleteFolder()
DriveExists()
FileExists()
FolderExists()
GetAbsolutePathName()
GetBaseName()
GetDrive()
GetDriveName()
GetExtensionName()
GetFile()
GetFileName()
GetFolder()
GetParentFolderName()
GetSpecialFolder()
GetTempName()
MoveFile()
MoveFolder()
OpenTextFile()

You can view a demo here

Blog Widget by LinkWithin

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment