First, create an Access database: testimg.mdb, the format is as follows:
id
[auto numbering ]
Name
[Text]
IMG
[OLE object]
Size
[Text]
Shouming
[Text]
Type
[Text]
date
[Time / Date]
Then establish the following two files:
Conn.asp
<% db_path = "testimg.mdb"
Set conn = server.createObject ("adoDb.connection")
Connstr = "driver = {Microsoft Access Driver (* .mdb)}; dbq =" & server.mappath (db_path)
Conn.open connStr%>
Showimg.asp
<% set = server.createObject ("adoDb.recordset")
SQL = "SELECT * from imgurl where id =" & trim (Request ("ID"))
RS.Open SQL, CONN, 1, 1
Response.contentType = RS ("Type") '
'Response.addheader "Content-Disposition:", "Attachment; FileName =" & RS ("Name")' This sentence If you open it, all file formats you upload will be identified, and the file name will also be identified. If you don't open, there is only a few file formats to be identified. The file name can not be identified; but there is a sentence to have a short shiver, and there is a profit and cons., So don't open it according to you. The actual situation is ok.
Response.binaryWrite RS ("IMG"). GetChunk (RS ("Size") 10)
Response.end
Rs.close
SET RS = Nothing
SET CONN = NOTHING%>
Establish index.asp. Used to upload files, show what you have uploaded, and its related information: The content is as follows:
* {Color: Blue; font-size: 14; text-decoration: none}
Table {background-color: blue}
TD {background-color: #ffffff}
A: Hover
{Color: # ff00; text-decoration: none}
style>
file name td> | file size td> | file instructions td > | Upload date td> | * td> tr> <% if Request ("p") = "" "" ""
strsql = "Select * from imgurl where name <> # 'Order by Date DESC" SET RS = Server.createObject ("AdoDb.Recordset") RS.Open Strsql, CONN, 1, 1 Do Until Rs.eof WhatID = RS ("ID") Name = RS ("Name") %> |
<% = Name%> td> |
<% = FormatNumber (RS ("Size" / 1024, 2)%> KB | <% = rs ("shUoming")%> td> td> | <% = RS ("Date")%> td> | Delete td> tr> <%
rs.movenext loop SET RS = Nothing Set conn = Nothing END IF %> TABLE> <% if Request ("p") = "DEL" THEN AA = Request ("p") SQL = "Update Imgurl Set Name = '#' where id =" & requirements ") Conn.execute SQL Set conn = Nothing Response.Redirect "index.asp" END IF %> The UPLOAD.ASP is then established to process uploaded files and save it to the database. The content is as follows: <% IF Request ("P") = "" "" "> * {Color: Blue; font-size: 12; Text-Decoration: none} A: hover {color: # ff0000; text-decoration: none} stop> |