AspJpeg

  • Thread starter Christopher Brandsdal
  • Start date
C

Christopher Brandsdal

Hello!
I am making a upload script for my images. I want the script to resize the
images automaticly.
The server supports AspJpeg but i don't have AspUpload.

Can anyone help me to implement the AspJpeg code into my upload code?


AspJpeg CODE.
'---------------------------------------------------------------------------
-----------------------
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
jpeg.Open( File.Path )

' resize image accoring to "scale" option.
' notice that we cannot use Request.Form, so we use Upload.Form instead.
jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

' AspJpeg always generates JPEG thumbnails regardless of original format.
' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath
'---------------------------------------------------------------------------
----------------------



MY UPLOAD CODE




'---------------------------------------------------------------------------
----------------

if Request.QueryString("action") = "upload" then
Server.ScriptTimeout = 1200
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

ByteCount = Request.TotalBytes

if ByteCount > Application("MaxFileSize2Upload") then
Response.Redirect "./select_image.asp?error=05"
end if


RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin

Dim aux, aux1
Dim ImageCateg, ContentType, FilePathName, FileName, Value

ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Value")) 'Image
Folder

on error resume next
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0

if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName =
Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if

Dim objFSO2
Dim objUploadFile

if FileName<>"" then
on error resume next
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
objUploadFile.Write getString(value)
objUploadFile.Close
FILEFLAG = err.number
on error goto 0
end if

Set objFSO2 = nothing
Set objUploadFile = nothing
Set UploadRequest = nothing

if FILEFLAG = 0 then
sUrl = "./select_image.asp?catid=" & Escape(ImageCateg) & "&dir=" &
Escape(sDir) & "&fld=" & Escape(sField)
else
sUrl = "./select_image.asp?error=02"
end if

Response.Redirect sUrl
End If


'---------------------------------------------------------------------------
----------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top