Using ASP technology to browse directories and files on Web pages

Source: Internet
Author: User
Tags ftp html tags key words
web| Web page Use ASP technology to browse directories and files on Web pages
Zhou Xiping
SummaryAt 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.
Key WordsASP WEB Document Files

Preface: On the intranet platform, the customer uses the Web browser to download the information from the server is a page composed of HTML tags, that is, the usual Web page, the page is generally divided into two categories, a simple static unchanged page, including text, tables and static images and other information, This page can be done by writing HTML markup text files or using page making tools such as FrontPage software, and dynamic interactive and intelligent pages that are complex to implement and require HTML markup, ActiveX controls and client-and server-side scripting languages, such as VBScript, JAVAScript, are grouped together to form Web applications, and Web programs run through the server and client processes to get the page. Although the production page has a dedicated page making tools to do, but to complete the page production need to master certain professional knowledge, such as HTML markup language, if you want to make dynamic interactive features of the page, the requirements are higher, need professionals to do. However, at present in many enterprises and institutions, the representation of data information is a lot of documents, such as word, EXCEL, WPS and TXT documents, these documents have become an important data information resources, the various departments of data sharing is through the query and copy each other's document files to achieve. If the document file is not converted, it can be queried and downloaded in the Web browser, then the efficiency of information processing will be improved, greatly reducing the workload of maintenance.
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.
Second, ASP technology and its objects
Starting with IIS3.0, Microsoft has launched active SERVER pages, ASP technology, which enables ASP to combine HTML pages, scripting languages (VBScript, JAVAScript), and ActiveX controls organically, creating dynamic, Interactive, efficient pages and powerful server applications based on Web databases.
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
Fullpath=server.mappath ("/DCW")
' 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
Folder=request ("folder")
If folder= "" Then
In_folder=request ("In_folder")
Out_file=request ("Out_file")
Prompt=request ("Prompt")
If in_folder<> "" and out_file<> ' then
Session ("In_folder") =in_folder
Session ("Out_file") =out_file
Session ("Prompt") =prompt
End If
Folder=session ("In_folder")
Prompt=session ("Prompt")
' Output folder name and hint information
Response.Write "

Else
Subfolder=folder
Folder=session ("In_folder") & Folder
' Output folder name and hint information
Response.Write "

End If
Asppath=request.servervariables ("Path_info")
' 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



Related Article

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.