Skip to main content
Known Participant
February 27, 2007
Question

uploading images

  • February 27, 2007
  • 12 replies
  • 783 views
i have done a tutorial for uploading images the images were going into the folder but when i added the command for uploading the data to the database nbothing is working now just wont display anything
browse file name = Filename
description = Description
form = form1

the name of the desription field is Description
file field = Filename
form = form1

'Add the details of the uploaded file to the database
Dim myFile, myDescription
myFile=Filename
myDescription=Uploader.Form("Description")

set cAddDetail = Server.CreateObject("ADOBE.Command")
cAddDetail.ActiveConnection = MM_robdalt_starsearch_STRING
cAddDetail.CommandText = "INSERT INTO tblUploadedFiles (Filename,
Description ) VALUES ( '" & myFile & "', '" &
myDescription & "' ) "
cAddDetail.CommandType = 1
cAddDetail.CommandTimeout = 0
cAddDetail.Prepared = true
cAddDetail.Execute()

anyone help
This topic has been closed for replies.

12 replies

Inspiring
March 1, 2007
This is how you want it. What you do is hardcode the path into your image tag. Like so:

<img src="../../images/uploadedFiles/<%=rs.fields.item("image").value%>">
Known Participant
March 1, 2007
got it bud cheers. The upload if fine sending the image to the folder and sending the data to database. But my image path in the database shows myimage.jpg

my folder where the image is is images/uploadedFiles/myimage.jpg i dont want to move my images how to i get the files path in my database to read

images/uploadedFiles/myimage.jpg
NOT myimages.jpg
Deaf_Web_Designer
Inspiring
February 27, 2007
I don't know much about ASP pretty much. Hopefully that there is other participants could help you with that. Let's cross your fingers and hoping that someone else chime in and offer you a better tip than I am. Sorry!
Known Participant
February 27, 2007
this is my ammended code but it still wont work if anyone can help me please do

Link
http://www.starsearchentertainment.com/fileUpload.asp


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/robdalt_starsearch.asp" -->
<!--#include file="Upload.asp" -->
<%
'Upload the image file and get reference to component
Dim Uploader, File
Set Uploader = GetASPUploader

'Use AddFile method to add file objects and change their properties as needed
Set File = Uploader.AddFile("file")
'The the properties of the upload
File.ValidFileTypes = "doc,pdf,txt,xls,mdb,jpg,gif,bpm,png"
File.MaxSize = 1024*1024
File.Overwrite = false 'Do not overwrite, create unique filename
'Set the folder name to where the file will be uploaded to
Uploader.Destination = "D:\hshome\robdalto\starsearchentertainment.com\images\uploadedfiles\"
'Set longer timeout for large files if needed
Server.ScriptTimeout = 900
'Enable error handling to catch and handle errors during upload. For example, if user cancels the upload or attempts to upload files of invalid (unallowed) type or size, ASPUploader will raise an exception (error) with relevant description

'Start receiving and saving file(s):
Uploader.Upload

'Check for errors:
If Err Then
'Redirect with error message
Response.Write err.description
Response.End()
End If

'Finally, void the object
Set Uploader=Nothing

'Add the details of the uploaded file to the database
Dim myFile, myDescription
myFile=Filename
myDescription=Uploader.Form("Description")

set cAddDetail = Server.CreateObject("ADODB.Command")
cAddDetail.ActiveConnection = MM_robdalt_starsearch_STRING
cAddDetail.CommandText = "INSERT INTO tblUploadedFiles (Filename,
Description ) VALUES ( '" & myFile & "', '" &
myDescription & "' ) "
cAddDetail.CommandType = 1
cAddDetail.CommandTimeout = 0
cAddDetail.Prepared = true
cAddDetail.Execute()

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

</body>
</html>
Known Participant
February 27, 2007
i have added a bit of code to close the <% but i still wont work its not coming up in my browser where the error is

Uploader.Destination = "D:\hshome\robdalto\starsearchentertainment.com\images\uploadedfiles\"
'Set longer timeout for large files if needed
Server.ScriptTimeout = 900
'Enable error handling to catch and handle errors during upload. For example, if user cancels the upload or attempts to upload files of invalid (unallowed) type or size, ASPUploader will raise an exception (error) with relevant description
On Error Resume Next


'Finally, void the object
Set Uploader=Nothing
%>
Known Participant
February 27, 2007
i see the opening tag at the top where do i put the closing tag
Known Participant
February 27, 2007
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/robdalt_starsearch.asp" -->
<!--#include file="Upload.asp" -->
<%
'Upload the image file and get reference to component
Dim Uploader, File
Set Uploader = GetASPUploader

'Use AddFile method to add file objects and change their properties as needed
Set File = Uploader.AddFile("file")
'The the properties of the upload
File.ValidFileTypes = "doc,pdf,txt,xls,mdb,jpg,gif,bpm,png"
File.MaxSize = 1024*1024
File.Overwrite = false 'Do not overwrite, create unique filename
'Set the folder name to where the file will be uploaded to
Uploader.Destination = "D:\hshome\robdalto\starsearchentertainment.com\images\uploadedfiles\"
'Set longer timeout for large files if needed
Server.ScriptTimeout = 900
'Enable error handling to catch and handle errors during upload. For example, if user cancels the upload or attempts to upload files of invalid (unallowed) type or size, ASPUploader will raise an exception (error) with relevant description
On Error Resume Next

'Start receiving and saving file(s):
Uploader.Upload

'Check for errors:
If Err Then
'Redirect with error message
Response.Write err.description
Response.End()
'Add the details of the uploaded file to the database
Dim myFile, myDescription
myFile=Filename
myDescription=Uploader.Form("Description")

set cAddDetail = Server.CreateObject("ADOBE.Command")
cAddDetail.ActiveConnection = MM_robdalt_starsearch_STRING
cAddDetail.CommandText = "INSERT INTO tblUploadedFiles (Filename,
Description ) VALUES ( '" & myFile & "', '" &
myDescription & "' ) "
cAddDetail.CommandType = 1
cAddDetail.CommandTimeout = 0
cAddDetail.Prepared = true
cAddDetail.Execute()
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

</body>
</html>
Deaf_Web_Designer
Inspiring
February 27, 2007
Active Server Pages error 'ASP 0116'

Missing close of script delimiter

/uploadThisFile.asp, line 4

The Script block lacks the close of script tag (%>).
Known Participant
February 27, 2007
the upload was working until i added the command i posted the command above and the details of my database fields
Known Participant
February 27, 2007
Deaf_Web_Designer
Inspiring
February 27, 2007
Can you post a link, so we can take a look at it and see what went wrong.