In ASP, the use of component or no component upload technology, can achieve file upload function. From this we can use ASP's no component upload technology, in our own website to build a virtual FTP server,
provides remote file management for multiple users, like a real FTP server, while individual users can only manipulate 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, nonsense told a lot, the following first talk about the implementation of the principles and methods, and then talk about the use of software implementation methods)
*****************
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.
Software Download Address:http://www.blue999.com/webfiles/uploadfiles_setup.exe
***************
(very complicated, simple, see below to use the "Upload File Manager" to implement the virtual FTP server method)
***************
1, download software installation, will be provided with the Software ASP files using FTP software uploaded to the site (such as upload webfiles)
2, the implementation of client software, and the server path set to upload folder, Super Administrator username and password are admin
3, user management, add, delete, modify, enable/disable, limit the size of user uploaded files
4, OK, virtual FTP server has been established, all users through the software (in the client) to their own file management. The software operates in a similar way as a resource manager.
5, the software also provides some examples of the application of ASP source code, we go to watch it.