Jac,
Here is what we've used in our ASP with ASPUpload. If you can get ASPUpload installed
this should do the trick. I've grabbed code that is used on a form to upload an event
and a picture. I pretty much striped out the extra code, only leaving in a few fields
to kind of leave a feel of the purpose of the form. Make sure your form has
'ENCTYPE="multipart/form-data".
<FORM name="eventform" onSubmit="return Validate();" ACTION="event_add_upd.asp"
METHOD=POST ENCTYPE="multipart/form-data">
<TABLE WIDTH=600 BORDER=0 CELLSPACING=2 CELLPADDING=2>
<TR>
<TD ALIGN="right" VALIGN="middle" width="150">
<span class="alerttext">*</span>
Title:
</TD>
<TD ALIGN="left" VALIGN="middle" width="450">
<INPUT TYPE=text NAME=title VALUE="" SIZE=40 MAXLENGTH=65>
</TD>
</TR>
<TR>
<TD ALIGN="right" VALIGN="middle" width="150">
Image:
</TD>
<TD ALIGN="left" VALIGN="middle" width="450">
<INPUT TYPE=file NAME=photofile VALUE="" SIZE=35 MAXLENGTH=75>
</TD>
</TR>
<TR>
<TD ALIGN="right" VALIGN="top" width="150">
<span class="alerttext">*</span>
Brief Desc:
</TD>
<TD ALIGN="left" VALIGN="middle" width="450">
<TEXTAREA NAME="desc" WRAP=soft ROWS=6 COLS=45 style='font:10pt
Arial'></TEXTAREA><BR>
</TD>
</TR>
</TABLE>
</FORM>
*** on the page you called from your form - in this case - event_add_upd.asp *****
'connection to database
<!--#include virtual="Intranet/library/dbConn.asp"-->
function repQuotes(varText)
tempStr=Replace(varText,"'","´")
repQuotes = replace(tempStr , Chr(34), Chr(38) + "quot" + Chr(59))
end Function
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = true
Upload.Save("c:\temp")
Set photo = Upload.Files("photofile")
If Not photo Is Nothing Then
If photo.ImageType <> "JPG" Then
Session("errmsg") = "JPG files only please!"
photo.Delete
Set photo = Nothing
Response.Redirect "events_add.asp"
End If
If photo.ImageWidth > 300 Then
photowidth = photo.ImageWidth
Session("errmsg") = "The photo you attempted to load is "&photowidth&"
pixels in width. All photos must NOT be larger than 300 pixels in width"
photo.Delete
Set photo = Nothing
Response.Redirect "events_add.asp"
End If
End If
'create ADO Connection and Recordset objects
Set MyConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
'open an updatable recordset to a SQL table named "events"
objRS.Open "events", strDBConn,2,3
IF err.number <> 0 then
Response.Write ("<br>Error - Connection<br>")
END IF
if instr(Upload.Form("title"), "'") Then
event_title = RepQuotes(Trim(Upload.Form("title")))
else
event_title = Trim(Upload.Form("title"))
end if
if instr(Upload.Form("desc"), "'") Then
event_brief_desc = RepQuotes(Trim(Upload.Form("desc")))
else
event_brief_desc = Trim(Upload.Form("desc"))
end if
'add new record
objRS.AddNew
objRS("event_title") = event_title
objRS("event_brief_desc") = event_brief_desc
If Not photo Is Nothing Then
objRS("photo_name") = photo.ExtractFileName
objRS("photo_height") = photo.ImageHeight
objRS("photo_width") = photo.ImageWidth
objRS("photo_file").Value = photo.Binary
photo.delete
End if
IF err.number <> 0 then
strMessage = "Sorry " & fName & " could not be uploaded.<br><br>The following
error occurred:" & err.description
else
strMessage = "File(s) uploaded successfully! "
END IF
'save changes and close recordset and database connection
objRS.Update
objRS.Close
'release resources
Set objRS = Nothing
Set Upload = Nothing
Response.Redirect "event_list.asp"
-Cheryl
-----Original Message-----
From: Ingentus [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 29, 2002 5:14 AM
To: [EMAIL PROTECTED]
Subject: [wdvltalk] uploading an image to DB
Hi folks,
Anyone got an ASP script handy that I could use to upload an image to a
database through a form? I'ver looked at ASPUpload but it seems a bit too
complicated. Any help with this would be appreciated.
TIA,
jac.
____ * The WDVL Discussion List from WDVL.COM * ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]