eNerGiZer0101
IS-IT--Management
Hello,
The following is my asp page. There are no errors in it. The only thing is that it does not upload the file from my html form. I think that the problem is from add file in current DB field. In my files table there are there fields: file_number, description and file. The fields file_number and description are filled when a file is uploaded but the file itself is not.
Is it possible for helpful advise for uploading a file in a MySQL database with asp forms.
<HTML>
<BODY BGCOLOR="white">
<H1>aspSmartUpload : Sample 4</H1>
<HR>
<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim oConn
Dim oRs
Dim intCount
intCount=0
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
' Connect to the DB
' *****************
set myconn = server.createobject("adodb.connection")
curDir = Server.MapPath("\database\files.frm")
connection = "DRIVER={MYSQL Connector/ODBC v5};SERVER=localhost;DATABASE=inse6120project;UID=root;PWD=root; OPTION=3; PORT=1433;"
myconn.open (connection)
' Open a recordset
' ****************
strSQL = "SELECT file, description FROM files"
Set oRs = Server.CreateObject("ADODB.recordset")
Set oRs.ActiveConnection = myconn
oRs.Source = strSQL
oRs.LockType = 3
oRs.Open
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Add the current file in a DB field
' **********************************
oRs.AddNew
file.FileToField oRs.Fields("file")
oRs("description") = file.FileName
oRs.Update
intCount = intCount + 1
End If
Next
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.<BR>")
' Destruction
' ***********
oRs.Close
myconn.Close
Set oRs = Nothing
Set myconn = Nothing
%>
</BODY>
</HTML>
The following is my asp page. There are no errors in it. The only thing is that it does not upload the file from my html form. I think that the problem is from add file in current DB field. In my files table there are there fields: file_number, description and file. The fields file_number and description are filled when a file is uploaded but the file itself is not.
Is it possible for helpful advise for uploading a file in a MySQL database with asp forms.
<HTML>
<BODY BGCOLOR="white">
<H1>aspSmartUpload : Sample 4</H1>
<HR>
<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim oConn
Dim oRs
Dim intCount
intCount=0
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
' Connect to the DB
' *****************
set myconn = server.createobject("adodb.connection")
curDir = Server.MapPath("\database\files.frm")
connection = "DRIVER={MYSQL Connector/ODBC v5};SERVER=localhost;DATABASE=inse6120project;UID=root;PWD=root; OPTION=3; PORT=1433;"
myconn.open (connection)
' Open a recordset
' ****************
strSQL = "SELECT file, description FROM files"
Set oRs = Server.CreateObject("ADODB.recordset")
Set oRs.ActiveConnection = myconn
oRs.Source = strSQL
oRs.LockType = 3
oRs.Open
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Add the current file in a DB field
' **********************************
oRs.AddNew
file.FileToField oRs.Fields("file")
oRs("description") = file.FileName
oRs.Update
intCount = intCount + 1
End If
Next
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.<BR>")
' Destruction
' ***********
oRs.Close
myconn.Close
Set oRs = Nothing
Set myconn = Nothing
%>
</BODY>
</HTML>