Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading a file in a MySQL database

Status
Not open for further replies.

eNerGiZer0101

IS-IT--Management
Jul 5, 2004
57
CA
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>



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top