Use XML + FSO + JS to implement server-side files

Source: Internet
Author: User
First, create a program on the server to generate an XML file to return to the client, (getfolder. asp) 0then allows you to set the types of returned files to prevent Source code leakage. write & quot; & chr (13) response. write & quot; file & quot; & chr (13) response. write

First, create a program on the server to generate an XML file to return to the client, (getfolder. asp) <% written by Linzhang Chen, 2003-4-20 reprinted, please indicate the source and retain this copyright information response. write" "& Chr (13) response. write" "& Chr (13) folders = request (" folder ") if folders ="/"then folders =" "end if dim count = 0 folders = replace (folders, ".. "," ") basefolder = ".. /media/"The baseline folder path newfolder = basefolder & folders Set fso = server. createObject ("Scripting. fileSystemObject ") set f = fso. getfolder (server. mappath (newfolder) set sf = f. subfolders for each fd in sf returns the response folder list under the specified path. write" "& Chr (13) response. write" Folder "& Chr (13) response. write" "& Fd. name &" "& Chr (13) response. write" "& Chr (13) count = count + 1 next set sf = nothing set ff = f. files for each fi in ff fname = fi. name if instr ("asf, wma, wmv", lcase (mid (fname, limit Rev (fname ,". ") + 1)> 0 then: specifies the file type that can be returned to prevent the source code from leaking response. write" "& Chr (13) response. write" File "& Chr (13) response. write" "& Fname &" "& Chr (13) response. write" "& Chr (13) count = count + 1 end if next if there is no file in the directory, send an empty element if count = 0 then response. write" "& Chr (13) response. write" Empty "& Chr (13) response. write" 0 "& Chr (13) response. write" "& Chr (13) end if response. write" "Set ff = nothing set f = nothing set fso = nothing %> below is the JS effort of the client (selectfile. asp) Select a video file Search range (I): File type (T): Streaming media files (*. asf, *. wmv, *. wma) There is also a small file named "blank.htm" to define the display style of files and folders. New Document When calling the following function, you can implement the function selectfile () {var arr = showModalDialog ("selectfile. asp? Temp = "+ Math. random ()," "," dialogWidth: Pixel px; dialogHeight: 252px; status: 0; help: 1 "); if (arr! = Null) {return arr} the function returns the selected file name, several images used in the function are automatically captured from the file selection box. :) It is estimated that you may encounter various unknown bugs during use. please contact me: E_mail: clzwin@sina.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.