<html> <head> <title>ThaiCreate.Com ASP & aspSmartUpload</title> </head> <body> <form action="AspSmartUpload8.asp" method="post" enctype="multipart/form-data" name="frmMain"> Upload <input name="file1" type="file"> <input type="submit" name="Submit" value="Submit"> </form> </body> </html>
<% Option Explicit %> <html> <head> <title>ThaiCreate.Com ASP & aspSmartUpload</title> </head> <body> <% Dim mySmartUpload Dim Conn,strSQL,objExec '*** Create Object ***' Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") '*** Upload Files ***' mySmartUpload.Upload '*** Upload file1 ***' If mySmartUpload.Files("file1").FileName <> "" Then mySmartUpload.Files("file1").SaveAs(Server.MapPath("MyFiles/" & mySmartUpload.Files("file1").FileName)) Response.write mySmartUpload.Files("file1").Name & " Uploaded.<br>" '*** Insert Record ***' Set Conn = Server.Createobject("ADODB.Connection") Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , "" strSQL = "" strSQL = strSQL &"INSERT INTO files " strSQL = strSQL &"(FilesName) VALUES ('"&mySmartUpload.Files("file1").FileName&"')" Set objExec = Conn.Execute(strSQL) End If Response.write("<a href=AspSmartUpload9.asp>View files</a>") '*** Properties ***' 'Response.Write("Name = " & mySmartUpload.Files("file1").Name & "<BR>") 'Response.Write("Size = " & mySmartUpload.Files("file1").Size & "<BR>") 'Response.Write("FileName = " & mySmartUpload.Files("file1").FileName & "<BR>") 'Response.Write("FileExt = " & mySmartUpload.Files("file1").FileExt & "<BR>") 'Response.Write("FilePathName = " & mySmartUpload.Files("file1").FilePathName & "<BR>") 'Response.Write("ContentType = " & mySmartUpload.Files("file1").ContentType & "<BR>") 'Response.Write("ContentDisp = " & mySmartUpload.Files("file1").ContentDisp & "<BR>") 'Response.Write("TypeMIME = " & mySmartUpload.Files("file1").TypeMIME & "<BR>") 'Response.Write("SubTypeMIME = " & mySmartUpload.Files("file1").SubTypeMIME & "<BR>") Set mySmartUpload = Nothing %> </body> </html>
<% Option Explicit %> <html> <head> <title>ThaiCreate.Com ASP & Microsoft Access Tutorial</title> </head> <body> <% Dim Conn,strSQL,objRec Set Conn = Server.Createobject("ADODB.Connection") Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , "" strSQL = "SELECT * FROM files " Set objRec = Server.CreateObject("ADODB.Recordset") objRec.Open strSQL, Conn, 1,3 %> <table width="200" border="1"> <tr> <th width="50"> <div align="center">Files ID </div></th> <th width="150"> <div align="center">Files Name </div></th> </tr> <% While Not objRec.EOF %> <tr> <td><div align="center"><%=objRec.Fields("FilesID").Value%></div></td> <td><center><a href="MyFiles/<%=objRec.Fields("FilesName").Value%>"><%=objRec.Fields("FilesName").Value%></a></center></td> </tr> <% objRec.MoveNext Wend %> </table> <% objRec.Close() Conn.Close() Set objRec = Nothing Set Conn = Nothing %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท