|
|
|
ขอโค้ดเก็บรูปภาพเข้าในฐานข้อมูลหน่อยครับ ขอโค้ดเก็บรูปภาพเข้าในฐานข้อมูลหน่อยครับหรือช่วยแนะนำจะเก็บรูปสมาชิก |
|
|
|
|
|
|
|
Code (AspSmartUpload7.html)
<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>
Code (AspSmartUpload8.asp)
<% 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>
Code (AspSmartUpload9.asp)
<% 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>
Ref : ASP aspSmartUpload - Upload files to Database
|
|
|
|
|
Date :
2009-09-13 09:07:24 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆๆครับพี่
|
|
|
|
|
Date :
2009-09-16 10:33:55 |
By :
man |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ครับอธิบายหน่อยได้ไหมครับ
ผมไม่รู้เรื่องเลยเกียวกับ กำลังศึกษาครับ
ขอบคุณครับ
|
|
|
|
|
Date :
2009-09-16 10:55:03 |
By :
sulyman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|