View Full Version : How can I upload images using ASP?
alingradinaru
06-19-2003, 04:09 AM
Hi!
I have a problem and I just don't know how to solve it:
I have a form on my web site and I have to add two "file objects" so the visitors can upload two images.
I have no idea how can I do this.
Please advise me.
It's my first web site and I just want to finish it.
PLease visit my personal web site; there you can download some cool wallpapers for free and no login required.
Thank you in advance for your help.
Best regards, A.G.!
sroughley
06-19-2003, 11:03 AM
Do a search in Google for:
"File Upload" "ASP"
Include the quotes and you will get plenty of results. ASP Pure File Upload is a good add in for Dreamweaver, but it does take quite a bit of fiddling with the code before it works flawlessly.
Regards.
Steve.
Angelika
06-19-2003, 11:40 AM
try this:
<html>
<head>
<title>New Page 1</title>
</head>
<body>
<form method="POST" name="Form" action="Upload_LogoImage_Do.asp" ENCTYPE="multipart/form-data">
<b>Select Image File:</b><input TYPE="file" name="FILE1" size="27">
<input type="submit" value="UPLOAD IMAGE NOW!">
</form>
</body>
</html>
-----------------------------------
Upload_Image_Do.asp
<%
On Error Resume Next
' Variables
' *********
Dim mySmartUpload
Dim file
Dim intCount
intCount=0
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Files Allowed List
' ***************
mySmartUpload.AllowedFilesList = "gif,jpg"
' Upload
' ******
mySmartUpload.Upload
' Trap errors
' ***********
If Err Then
Response.Write("<b>Wrong selection : </b>" & Err.description)
End If
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Save the files with his original names in a virtual path of the web server
' sample with a physical path
' file.SaveAs("c:\temp\" & file.FileName)
' ****************************************************************************
file.SaveAs("Path" & file.FileName)
FileExtension = file.FileExt
FileName = file.FileName
' Display the properties of the current file
' ******************************************
'Response.Write("Name: = " & file.Name & "<BR>")
'Response.Write("Size: = " & file.Size & "<BR>")
'Response.Write("File Name: = " & file.FileName & "<BR>")
'Response.Write("File Extention: = " & file.FileExt & "<BR>")
'Response.Write("File Path Name: = " & file.FilePathName & "<BR>")
'Response.Write("Content Type: = " & file.ContentType & "<BR>")
'Response.Write("Content Disp: = " & file.ContentDisp & "<BR>")
'Response.Write("Type MIME: = " & file.TypeMIME & "<BR>")
'Response.Write("SubType MIME: = " & file.SubTypeMIME & "<BR>")
intCount = intCount + 1
End If
Next
' Display the number of files which could be uploaded
' ***************************************************
Response.Write(mySmartUpload.Files.Count & " files could be uploaded.")
' Display the number of files uploaded
' ************************************
Response.Write("intCount & " file(s) uploaded.")
%>
he'll need the aspSmartUpload component before he can instantiate the object. Otherwise he'll get a nice fat error saying : Server object, ASP 0177 Invalid ProgID
Angelika
06-19-2003, 03:09 PM
aspSmartUpload is a FREE ASP component wich provides you with all the upload/download features you need to transfer files to a server using a browser.
http://www.15seconds.com/component/pg000025.htm
jsawkang
06-19-2003, 08:42 PM
yupe.
i'm using ASPSmartUpload component as well.
Bullschmidt
06-20-2003, 07:53 AM
I have a form on my web site and I have to add two "file objects" so the visitors can upload two images.
First let's deal with the timeout issue which can be a problem if a user is uploading a fairly large file (although perhaps you don't want the timeout increased too much because you DON'T want a user uploading a large file).
For pure ASP (i.e. non component) solutions (and I believe this would be true for component solutions too) can increase the timeout for the page:
' Script timeout in seconds for this page.
' (60 x 60 = 1 hour.)
Server.ScriptTimeout = 60 * 60
Also the Anonymous Internet user needs Change permission on the folder that a file is going to be uploaded to and actually Full Access might be better if you are later going to use the FileSystemObject to delete a file.
Here is a resource for letting the user upload a file which is something that was unfortunately not built into ASP:
ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
http://www.aspzone.com/articles/john/aspUpload
UltraFastAspUpload by Cakkie (http://home.planetinternet.be/~aerts1) - 1/3/2002
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7093&lngWId=4
pustiweb
03-24-2006, 08:19 AM
I have tried what you had suggested. but it gives me error.
You can check my file here :
http://www.pushtiwebindia.com/w3jmailupload/sample2.htm
Urgent!!!
Awaits for your reply
Gaurang
Pushtiwebindia.com, Website designing in mumbai, India
try this:
<html>
<head>
<title>New Page 1</title>
</head>
<body>
<form method="POST" name="Form" action="Upload_LogoImage_Do.asp" ENCTYPE="multipart/form-data">
<b>Select Image File:</b><input TYPE="file" name="FILE1" size="27">
<input type="submit" value="UPLOAD IMAGE NOW!">
</form>
</body>
</html>
-----------------------------------
Upload_Image_Do.asp
<%
On Error Resume Next
' Variables
' *********
Dim mySmartUpload
Dim file
Dim intCount
intCount=0
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Files Allowed List
' ***************
mySmartUpload.AllowedFilesList = "gif,jpg"
' Upload
' ******
mySmartUpload.Upload
' Trap errors
' ***********
If Err Then
Response.Write("<b>Wrong selection : </b>" & Err.description)
End If
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Save the files with his original names in a virtual path of the web server
' sample with a physical path
' file.SaveAs("c:\temp\" & file.FileName)
' ****************************************************************************
file.SaveAs("Path" & file.FileName)
FileExtension = file.FileExt
FileName = file.FileName
' Display the properties of the current file
' ******************************************
'Response.Write("Name: = " & file.Name & "<BR>")
'Response.Write("Size: = " & file.Size & "<BR>")
'Response.Write("File Name: = " & file.FileName & "<BR>")
'Response.Write("File Extention: = " & file.FileExt & "<BR>")
'Response.Write("File Path Name: = " & file.FilePathName & "<BR>")
'Response.Write("Content Type: = " & file.ContentType & "<BR>")
'Response.Write("Content Disp: = " & file.ContentDisp & "<BR>")
'Response.Write("Type MIME: = " & file.TypeMIME & "<BR>")
'Response.Write("SubType MIME: = " & file.SubTypeMIME & "<BR>")
intCount = intCount + 1
End If
Next
' Display the number of files which could be uploaded
' ***************************************************
Response.Write(mySmartUpload.Files.Count & " files could be uploaded.")
' Display the number of files uploaded
' ************************************
Response.Write("intCount & " file(s) uploaded.")
%>
Nook Schreier
04-07-2006, 12:43 PM
Response.Write("intCount & " file(s) uploaded.")
Remove the quote before intCount
vBulletin v3.0.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.