Implement server-side files with Xml+fso+js

Source: Internet
Author: User
The fso|js|xml| server first creates a program on the server side to generate an XML file to return to the client, (getfolder.asp)
<%
' Written by Linzhang Chen, 2003-4-20
' Reprint please indicate the source and retain this copyright information
Response.Write "<?xml version=" "1.0" "encoding=" "GB2312" "?>" &AMP;CHR (13)
Response.Write "<mediafile>" &AMP;CHR (13)
Folders=request ("folder")
If folders= "/" Then
Folders= ""
End If
Dim count
Count=0
Folders=replace (folders, "..", "")
Basefolder= ". /media/"' Reference to the 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 list of folders below the specified path
Response.Write "<file>" &AMP;CHR (13)
Response.Write "<ftype>folder</ftype>" &AMP;CHR (13)
Response.Write "<fname>" &fd.name& "</fname>" &AMP;CHR (13)
Response.Write "</file>" &AMP;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,instrrev (fname, ".") +1)) >0 Then ' set the file type to allow return, prevent source leakage
Response.Write "<file>" &AMP;CHR (13)
Response.Write "<ftype>file</ftype>" &AMP;CHR (13)
Response.Write "<fname>" &fname& "</fname>" &AMP;CHR (13)
Response.Write "</file>" &AMP;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 "<file>" &AMP;CHR (13)
Response.Write "<ftype>empty</ftype>" &AMP;CHR (13)
Response.Write "<fname>0</fname>" &AMP;CHR (13)
Response.Write "</file>" &AMP;CHR (13)
End If
Response.Write "</mediafile>"
Set ff=nothing
Set f=nothing
Set fso=nothing
%>
The following is the client's JS Kung Fu (selectfile.asp)
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> Select Video File </TITLE>
<style>
TD{FONT-SIZE:9PT}
SELECT{WIDTH:210}
. s2{width:250}
</style>
<script language= "JavaScript" >
<!--
/*written by Linzhang Chen, 2003-4-20
Reprint please specify the source and retain this copyright information * *

Pre-loaded pictures
var imgback = new Image ();
IMGBACK.SRC = "Http://www.163design.net/a/o/images/arrow.gif";
var imgbackgray = new Image ();
IMGBACKGRAY.SRC = "Images/grayarrow.gif";
var imgfolder = new Image ();
IMGFOLDER.SRC = "Images/folder.gif";
var imggrayfolder = new Image ();
IMGGRAYFOLDER.SRC = "Images/grayfolder.gif";
History array Stack
var arrhistory=new Array ();
var hisi=0;
Used to determine the file name to return
function Check ()
{
if (document.all.filename.value== "")
{
Alert ("Please select File First");
return false;
}
Else
{
Window.returnvalue =document.f1.folder.value+document.all.filename.value;
Window.close ();
}
}
Get the contents of an XML file
function getuserlist (URL)
{var oxmldoc = new ActiveXObject (' MSXML ');
Oxmldoc.url = URL;
var ooroot=oxmldoc.root;
return ooroot;
}
When a file is selected, return the value to the text box
function AddFile (TXT)
{
Document.all.filename.value=txt;
}

var first=1;//defines a global variable

function userlist (folders,ti)/list the selected boxes
{document.f1.folder.value=folders;
Filebox.document.body.innerhtml= "Loading file, please wait ...";
var strshow= "";
var timeoutid=null;
var newfolder= "";
var arrfolder=new Array ();
var arrff=new Array ();
var blankstr= "";
var oitem;
Determine historical status
Hisi+=ti;
Arrhistory[hisi]=folders;
if (hisi==0)
{
Arrow.innerhtml= "}
Else
{
Arrow.innerhtml= " ';
}
Determine the current folder
if (document.f1.folder.value== "")
{
Folderid.innerhtml= "}
Else
{Newsfolder=checkfolder (Document.f1.folder.value)



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.