Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP code for browsing folders? 1

Status
Not open for further replies.

boein

Technical User
Jul 17, 2003
84
BE
Hi all,
I'm not an asp nor an html programmer so I could need some help here. I have a webpage that I use to show the contents of a folder with its subfolders. In IIS I enabled "directory browsing" for this virtual directory. This works fine, people can browse and select files but this html-generated directory layout is ugly as hell. Files and directories are mixed together, and it's very confusing to see the difference between a directory and a file. Is it possible to create a html page where the directories and files are grouped together (like in an windows explorer) with the folder-icons and file-type icons (for example an xls-icon for an excel sheet...)
How can you do this, or can somebody give me the code (asp?) to do this?

Thanks

Wim




 
not a trivial operation for a non-programmer Stardeveloper article.

Showing the icons adds a bit more complexity. It will need icons in a folder on the webserver, as ASP cannot run the API calls needed to get the icon from the system. Your code will then have to find the file extension and show the correct icon.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Yes I know ;-)

Icons is not really necessary if it's too difficult. If the folders and files in the view aren't mixed anymore I'd be more than happy.
Is this difficult to accomplish?

Thanks
Wim
 
not specially difficult for a programmer and the article gives all the code you will need, you will just need to tweak the display to suit your needs.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
i have a fairly small asp page i put together that uses FSO to make a windows explorer style interface nothing spectacular but might give you some ground to build off of.
also included in the zip is a download.asp that will allow you to download any file you see in the file list. ( by double clicking )

there's a few little issues in it, there's some documentation at the top of the explorer.asp file enclosed.
images for folders/cdroms/floppys etc are all included.


last note... server availability is only between CST hours of 8am and 10pm

hope the info helps.


[thumbsup2]DreX
aKa - Robert
 
Thanks Robert,

looks nice. If I only want to show a certain directory and no drives (on the left side) what lines do I have to modify in these scripts?

Thanks

Wim
 
well you'd need to disable the call to drives()

and as for a certain directory .. i think the variable was currentpath, you can set that = the folder you desire

[thumbsup2]DreX
aKa - Robert
 
If I disable the call to drives(), the left column is empty. This is a problem because I cannot go up one level in the tree because there is no tree to click on. Is it possible to only show a tree on the left side of a certain directory (no drives!!!). Users may only see this directory, and browse within this directory and its subdirectories.
Can you also display file attributes (creation date, file size...etc).
If I want to copy the internet shortcut to a file on the directory, it's not possible with R-click on file and select "copy shortcut". Is it possible to enable this feature?

Thanks
Wim
 
the right click copy shortcut would not work because this is all mapped via FSO basically you're able to look at things that are outside of your web space, and because of that there is no .. "shortcut" to the file other than being mapped via a FSO downloader. as for the folder listing, you need to look at the functions at the base of the page, first calls the second etc etc.. disable the drives call, and use the passed value of currentfolder to set the path ( from a click in the page ), otherwise set a value for currentfolder = whatever path, this will disable the drives list and "force" browsing within a certain folder set, although you could technically put the path right into the query string and go where ever you want, so this is a security issue, make sure you have this file locked down fairly well. now as for a direct link to the files i guess that could be done by replacing the onclick javascript to an href to download.asp?filename=file.path
i'm still in the works of making this DB based so that file ID's could be passed instead of physical paths. but that's a low level project on my plate and probably wont get worked on for quite some time.

file attributes, in the make filelist function, just add a column for attributes, look up FSO and how to use it's methods, attributes are base2 binary value ( 1,2,4,8,16,32,64 etc )combination and the breakdown of which will tell you the attribs assigned to a file or folder, you'll probably need a function for that.

i hope the info helps, and i'm still glad to answer further questions.

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top