Image Uploading (again...)
hey guys... new to this forum....
i have read a few posts... but (as you can guess) with no success....
well, as title says.. i have some problems with image uploading...
i'm using MS SQL Server 2003
coding in Visual Basic
and running asp pages to control a the dll....
so well the save function in the dll is:
VB Code:
Public Function SaveRecord() As Long
ConnectToDb
Dim strSQL As String
Dim rs As ADODB.Recordset
strSQL = "Select * from tblDb"
Set rs = New ADODB.Recordset
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!imgFile = imgFile
rs!imgName = imgName
rs.Update
SaveRecord = rs!RecordId
rs.Close
End Function
Then as you can guess htere is a posting page (insert.html)
Code:
<form id="Inserimento" method="post" action="save.asp" ENCTYPE="multipart/form-data">
<tr><td><input type="file" name="imgFile" size="25"></td>
<td><input tabindex=0 type=text name="imgName" size=30></td>
<!--...continues with more boxes.. -->
and the save.asp page which calls the dll....
Code:
<%@ language=VBScript %>
<%Option Explicit %>
<html>
<head>
<title>Inserimento Eventi</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<%
Dim imgFile
Dim imgName
imgFile = Request.Form("imgFile")
imgName = Request.Form("imgName")
Dim x
set x = Server.CreateObject("project.class")
x.GetimgFile(imgFile)
x.GetimgName(imgName)
x.SaveRecord
set x = nothing
'response.redirect("insert.html")
%>
</body>
</html>
----------------
displaying:
VB Code:
Public Sub SearchRecordId()
Dim x As Long
ConnectToDb
Dim strSQL As String
Dim rs As ADODB.Recordset
strSQL = "Select * from tblDb where RecordId=" & lngRecordId
Set rs = New ADODB.Recordset
rs.Open strSQL, cnn, adOpenKeyset
If rs.RecordCount = 0 Then Exit Sub
'-----------------------------
imgFile = rs!imgFile
imgName = rs!imgName
'-----------------------------
rs.Close
End Sub
VB Code:
Public Function ReturnViewImage() As String
ReturnViewImage = imgFile
End Function
asp page:
Code:
<%
Dim strSearch
Dim lngRecordID
lngRecordID = Request.QueryString("ID")
Dim x
set x = Server.CreateObject("Project.Class")
x.GetRecordID(lngRecordID)
x.SearchRecordID
response.binarywrite(x.ReturnViewImage)
set x = nothing
%>
the last asp page requests the id from another page (and it works great...)
but the image is not returned... any ideas?
should i post ALL the code?
thx
ac3bf1
Re: Image Uploading (again...)
Could u not store the image on your local server? Then you can simple have the path instead of the image in your database? This would definitely be easier right?
Re: Image Uploading (again...)
hi,
i would also go with abhijeet, to store image in server and use the path. if you are willing then try the attached one. it works fine in all of my websites..
Re: Image Uploading (again...)
well yeah.. i have though about that but i actualy wanted to have all in a database.... also becausse people cant touch the images if they r stored on a DB...
while ina folder they would be easily touched, modified, renamed... etc....
its an application for archiving small images..... no bigger than 300x300 pixels jpg formats low res.. :P
any ideas? if u want i can post all the code in :)
ac3bf1