How to use ASP to establish a virtual FTP server (top)

Source: Internet
Author: User
Tags end file upload ftp file manager download access
FTP Server |FTP Server in ASP components or no component upload technology, can achieve file upload function. From this we can use ASP's no component upload technology, in our own site to build a virtual FTP server, like a real FTP server, for multiple users to provide remote file management, while each user can only operate their own files.

When the file upload, the ASP can use the FSO or database way to save the file data (some servers do not provide FSO function). Here I use the database to save the user uploaded files, the advantages of using the database I do not say, in short a lot. Another reason is that IIS limits the size of the file upload (probably the largest 200KB bar), using the database method can use the continuation of the technology to break through this limit, you can upload a large file, very large, infinite, ...

(Haha, a lot of nonsense, the following talk about the implementation of the method)

The first step: Create a database on the server (access, Sql-server, MySQL can be), easy to access it. Two tables are created in the database:
Upload user admin: admin (ID, Name, Password, Type)
Save uploaded file data: Files (ID, ParentID, FileName, Filelength, FileType, Filedata, UpDate, UserID).
If filelength=0, it is a folder, and a root folder is established for each user.

Step Two: Create a user login page, and use session to save the user's ID to restrict its operation to the file.
Session ("Name") = List ("Sname")
Session ("UID") = List ("ID")

Step three: Create the user's homepage (display the file that the user uploaded)
strSQL = "SELECT * from Files WHERE parentid=" & Userrootid ' Userrootid is the ID of the user's root folder
strSQL = strSQL & "and Userid=" & Session ("UID")
strSQL = strSQL & "ORDER by FileName"

Fourth step: Upload File page
List. AddNew
List ("ParentID") = Userrootid
List ("FileName") = Form ("Name")
List ("filelength") = Form ("Length")
List ("FileType") = Form ("Type")
List ("Filedata"). AppendChunk MidB (Sdata,form ("Start"), Form ("Length")
List ("UserID") = Session ("UID")
List ("UpDate") = Now ()
List. Update

Step Fifth: File management operations (use the ID of the file to identify the file and restrict the user's actions)
Delete: "Delete * from files WHERE id=" & IID & "and Userid=" & Session ("UID")
Download: "Select * from Files WHERE id=" & IID & "and Userid=" & Session ("UID")

Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open Myconnstr
Set list = conn. Execute ("SELECT * from Files WHERE id=" & IID & "and Userid=" & Session ("UID"))
If not list. EOF Then
If list ("Filelength") > 0 Then
Response.AddHeader "Content-disposition", "inline"; Filename= "& List" ("FileName")
Response.ContentType = List ("FileType")
Response.BinaryWrite (List ("Filedata"). GetChunk (List ("Filelength"))
End If
End If

Some other auxiliary operation pages can be completed. Of course, due to browser restrictions, file Upload technology can not be used directly, only through the client software to achieve. There is a software on the network called "Upload File Manager" (including ASP source code), achieve the above function. Here we will discuss how to use this software to build our own virtual FTP server.

Upload File Manager Download address: Http://www.blue999.com/webfiles/uploadfiles_setup.exe



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.