web| Web page
ASP technology to browse directories and files on Web pages
At present, in many units, such as Word, Excel or WPS, such document files have become important data information resources, how to manage these information resources efficiently on intranet Web platform is a problem to be solved. This article is the use of ASP technology to develop a web-based application, the implementation of the Web page browsing directory files, it is easy to do such as Word, Excel and WPS document files such as access and download, greatly reduce the workload of information maintenance.
ASP WEB Document Files
This article is the use of ASP technology to browse folders and files on the Web page, through the hyperlinks to view the relevant ActiveX document information, its function is similar to the FTP service, but more than FTP services can be better, one, more user-friendly interface, with the Web page seamless connection; second, easy to control, safe, The document that you need to view is displayed on the page and the document should not be seen.
technology and its objects
One feature of the ASP is that it has powerful built-in objects with many methods and properties. When developing Web application with ASP, it can call its object and its method, not only improve programming efficiency, but also optimize program code.
1, ASP includes six built-in objects:
The Request object is to obtain information from the client
Response object to send information to client
User information stored in a session by the Session object
Application objects allow different clients to share information within a asp-application
The Server object provides some methods used by the service side. Several methods of this object are used in the ASP program of this paper, which will be explained in detail later.
ObjectContext objects can work with Microsoft Transaction Server for distributed transactions
2, the server object important method
The CreateObject method CreateObject method is used to create an instance of an ActiveX component variable that has been registered to the server. For example, in the ASP program to browse folders and files, you must first use the CreateObject method to establish FileSystemObject object variable instance FS, and then call the object variable FS method to get folders and files (file), The following is an ASP code that gets the folder object that is/DCW:
' First set up FileSystemObject
Set Fs=server. CreateObject ("Scripting.") FileSystemObject ")
' Get the actual path to the/DCW folder
' Create a Folder object for/DCW
Set Fd=fs.getfolder (FullPath)
The MapPath method transforms the Web server virtual path to the server-side actual path. If on the IIS Web server assume that there is a real path to the C:\ Finance Department, when the Web virtual path is set up named DCW, writing format is/DCW, in fact Server.MapPath ("/DCW") is its actual path C:\ Finance department. Generally, the URL used in Web application browsing is the virtual path, and the actual path is used in the file access process, as in the previous set Fd=fs.getfolder (fullpath) statement, FullPath is represented as the actual path
The UrlEncode method encodes special characters in a URL as a string based on the URL encoding principle
The HTMLEncode method encodes an HTML file in ASCII form using the HTMLEncode method
Third, the implementation process
Client sends request information to server
The client sends the request information to the server side as an ASP file listf.asp and three parameter in_folder,out_file,prompt.
In_folder is represented as the folder to browse
Out_file indicates that the page returned to is exited
Prompt indicates the message on the page that lists the folder
To browse the "C:\ Finance" folder information, for example, its Web virtual directory is "/DCW", the program exits back to the home page, and the virtual path to the home page can be represented as "/" and the message is "financial data information." You can view all subfolders and files under the C:\ Finance folder by adding the following statement to your WEB program.
<a href=listf.asp?in_folder=/dcw&out_file=/&prompt= Financial Data Information > Financial Document Information </a>
' File start
' 2, get the parameter information
If folder= "" Then
If in_folder<> "" and out_file<> ' then
Session ("In_folder") =in_folder
Session ("Out_file") =out_file
Session ("Prompt") =prompt
' Output folder name and hint information
Folder=session ("In_folder") & Folder
' Output folder name and hint information
' 3, establish the folder object variable instance FD
Set fs= Server.CreateObject ("Scripting.FileSystemObject")
Set fd= Fs.getfolder (Server.MapPath (folder))
' 4, constructing the hyper-join function