YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Uploading an image file to the server with ASP. How to? Options
Matt
#1 Posted : Friday, February 19, 2010 3:36:40 PM
Rank: Newbie


Groups: Registered

Joined: 7/10/2009
Posts: 6
Location: Las Vegas Nv
I am trying to allow a user to upload image files onto my server, but am having trouble on getting the file from the client to the server. Any suggestions from anyone out there how I would do this? I dont see this as a basic function within ASP.
barrob326
#2 Posted : Monday, February 22, 2010 10:20:00 AM
Rank: Member


Groups: Registered

Joined: 7/10/2009
Posts: 21
Location: So California
I did this several years ago in ASP code using a couple tools provided by Persits. AspUpload and ASPJPeG. These are a couple of objects that seem to support uploading of files or images very well. The ASPJPEG object worked great for dynamic resizing of those images.

Below is a piece of sample code using these objects.

<%

dim i
dim Session_ID, User_ID, User_Name, Study_ID, Schema_ID, Compile, Page
dim FolderList, DocCategory, DocumentLoaded, ReturnDocURL

'Default this value
DocumentLoaded = "False"


Dim sResult
Dim Upload
Dim Count
Dim File
Dim LocalDocPath
Dim UniqueID
Dim Jpeg
Dim Path

sResult = "NONE"
UniqueID = Request.QueryString("UniqueID")

If Request.QueryString("DocUpload") = "True" Then
sResult = "Local Upload"
Set Upload = Server.CreateObject("Persits.Upload.1")

' Optional: make sure file names are unique when calling File.SaveAs
Upload.OverwriteFiles = True

Count = Upload.SaveToMemory

If Count > 0 Then ' 1 file uploaded
Set File = Upload.Files(1)

' Side effect: SaveAs sets changes File.Path property to a new value.
TempDocPath = cstr(Session("AutoImage") & "\" & cstr(UniqueID) & "_Orig.jpg")

File.SaveAs cstr(TempDocPath)

DocumentLoaded = "True"

' Create an instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Compute path to source image
Path = cstr(Session("AutoImage") & "\" & cstr(UniqueID) & "_Orig.jpg")

' Open source image
Jpeg.Open Path

' Create popup page larger picture
Jpeg.Width = 700
Jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth

' Optional: apply sharpening
Jpeg.Sharpen 1, 150

' Create thumbnail and save it to disk
Jpeg.Save cstr(Session("AutoImage") & "\" & cstr(UniqueID) & ".jpg")

' Create Detail page picture
Jpeg.Width = 289
Jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth

' Optional: apply sharpening
Jpeg.Sharpen 1, 150

' Create thumbnail and save it to disk
Jpeg.Save cstr(Session("AutoImage") & "\" & cstr(UniqueID) & "_med.jpg")

' Create Thumbnail
Jpeg.Width = 100
Jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth

' Optional: apply sharpening
Jpeg.Sharpen 1, 150

' Create thumbnail and save it to disk
Jpeg.Save cstr(Session("AutoImage") & "\" & cstr(UniqueID) & "_small.jpg")

on error resume next
Set Upload = Nothing
Set Jpeg = Nothing

Else
sResult = "No files found for uploaded."
End If
End If

%>
Please submit any questions or comments through my website.

http://www.qualitysoftwaredesign.com
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.3 | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.166 seconds.