PDA

View Full Version : FileSystemObject


scriptkeeper
07-22-2003, 01:13 AM
I stumbled upon this script and was just wondering if you could shuffle through files in clients drive rather than the servers drive

<%
'*****************************************************
'* Code written by Alexander Haneng (C) 1998-2001 *
'* FREE download from http://www.haneng.com/ *
'*****************************************************
%>

<HTML><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000" VLINK="#000000">
<BR>
<B>My file archive:</B><BR><BR>
<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0>
<TR BGCOLOR="#000000"><TD><FONT COLOR="#FFFFFF"><B>Filename:</B></FONT></TD><TD><FONT COLOR="#FFFFFF"><B>Size:</B></FONT></TD><TD><FONT COLOR="#FFFFFF"><B>File type:</B></FONT></TD><TD><FONT COLOR="#FFFFFF"><B>Date created:</B></FONT></TD>
<%
' Create an instance of the FileSystemObject
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
' Create Folder Object
Set MyFolder=MyFileObject.GetFolder(Server.MapPath("resident"))
'Loop trough the files in the folder
FOR EACH thing in MyFolder.Files
%>
<TR BGCOLOR="#F7F7E7"><TD><A HREF="resident/<%=thing.Name%>"><%=thing.Name%></A></TD><TD ALIGN=RIGHT><%=thing.Size%>bytes</TD><TD><%=thing.Type%></TD><TD><%=thing.DateCreated%></TD>
<%
NEXT
%>
</TABLE>
</BODY></HTML>

oracleguy
07-22-2003, 03:16 AM
No you can't, ASP is server side, it executes on the server so you can't browse a client's computer.

Morgoth
07-22-2003, 03:21 AM
What what you want to do, you must use javascript or any other client side scripts.

scriptkeeper
07-22-2003, 03:34 AM
I know that but is it done the same way through the FileSystemObject in javascript to I tried but I cant get it to work?

Spudhead
07-22-2003, 05:01 PM
You can't use FileSystemObject because it's a server - ASP - object. You do Server.CreateObject("Scripting.FileSystemObject")

Web pages accessing files on user's own machines is, rather obviously, something of a security issue. It's certainly possible to create the appearence of this using ordinary links and a bit of guesswork, but anything more... substantial.... is going to require breaking in to the machine in question.

Roelf
07-22-2003, 06:37 PM
using the filesystemobject client-side:

var fso = new ActiveXObject("Scripting.FileSystemObject");

then do the stuff like in ASP only use javascript syntax

remember though, you see it is an activeX object, so IE-only and visitors must have their website securitysettings low enough to allow the activeX to work......

oracleguy
07-22-2003, 09:15 PM
Originally posted by Roelf
remember though, you see it is an activeX object, so IE-only and visitors must have their website securitysettings low enough to allow the activeX to work......

Which isn't very common, correct?

whammy
07-23-2003, 01:05 AM
More common than you might think... usually IE will pop up a warning.

I don't know if you're familiar with it, but some people (like my Dad) who hadn't installed critical updates from Microsoft have run into ActiveX scripts that have written a new homepage into the registry, etc. and then put some kind of code in to stop you from going to windowsupdate.microsoft.com!

So you can see the reasons for the security warning on computers that are up to date... anyway, yeah you can do it through ActiveX, but only on Microsoft systems, and only if the user is using Internet Explorer.

I personally don't bother with anything like that. It not only worries the user, but there's not much use for it - web apps shouldn't write (or be allowed to write TO) to files on your computer (unless it's a cookie), that's what REAL applications are for.

scriptkeeper
07-23-2003, 04:13 AM
I just wanted to find a way to make my javascript slideshow allow the user to specify a folder and then have it dynamicaly grab the contents of that directory! Using the image files in the slideshow and the only way I can think of is this way! But if it is so much work and hassle maybe Ill forget it!

glenngv
07-23-2003, 10:29 AM
you can do it without security restrictions using HTA. I have already created a slideshow that allows user to specify the folder to get files from. If you want, I can give you the code.