Forums

ASP

This topic is locked

uploading images

Posted 27 Feb 2007 02:42:25
1
has voted
27 Feb 2007 02:42:25 Rob dalton posted:
i have done a tutorial for uploading images to a folder and data to the database the images were uploading until i added the command here is the code if anyone can see anything wrong can they let me know

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()

Replies

Replied 27 Feb 2007 21:07:56
27 Feb 2007 21:07:56 Rob dalton replied:
heres my amended code but still not workin the images were uploading to the folder until i added the command


<%@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" "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>

Reply to this topic