%@ Language=VBScript %>
<%
on error resume next
Response.Buffer = false
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Declare upload progress, upload objects, initialize
Dim upl, NewFileName, strSuccess
Set upl = Server.CreateObject("Persits.Upload")'Server.CreateObject("ASPSimpleUpload.Upload")
dim UploadProgress, PID, barref
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
Upl.ProgressID = Request.QueryString("PID")
PID = "PID=" & UploadProgress.CreateProgressID()
barref = "framebar.asp?to=10&" & PID
%>
Upload an Image to Use at HomeRepairForum.com
<%
if Request.ServerVariables("Request_method") = "POST" then
' Prepare upload directories
dim count, newPath
NewFileName = "/images/uploads/"
newPath = server.MapPath(newFileName)
' Limit file size to 50000 bytes, throw an exception if file is larger
Upl.SetMaxSize 1200000, True '1200 KB size limit' 900 KB size limit '500000, True
count = upl.Save(newPath & "/originals/")
'Response.Write count
' 8 is the number of "File too large" exception
If Err.Number = 8 Then
Response.Write "Your file is too large. Please try again.
"
Response.end
Else
End If
dim File, sOrigFile
set File = upl.Files("txtPicture")
sOrigFile = File.Filename
'write images to server
if sOrigFile = "" then
Response.Write "No file was entered. Please press your browser's back button to try again.
"
end if
If Len(sOrigFile ) > 0 then 'Len(upl.Form("txtPicture")) > 0 Then
NewFileName = NewFileName & "originals/" & sOrigFile'upl.ExtractFileName(upl.Form("txtPicture"))
If File.ImageType <> "UNKNOWN" then'upl.SaveToWeb("txtPicture", NewFileName) Then
strSuccess = strSuccess & "
" & sOrigFile & " successfully written to disk."
boolSuccess = true
' Create instance of AspJpeg
dim Jpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Open source image
'Response.Write server.MapPath(NewFileName)
Jpeg.Open server.MapPath(NewFileName)
Jpeg.Interpolation = 2
dim aFileParts, s550File
aFileParts = split (sOrigFile, ".")
s550File = year(date()) & "-" & month(date()) & "-" & day(date()) & "_" & replace(replace(aFileParts(0)," ","_"),"&","") & "_w550." & aFileParts(1)
'Response.Write s550File
'create and save the 550 pixel width image
if Jpeg.Width > 550 then
Jpeg.Width = 550
jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
end if
Jpeg.Save newPath & "\" & s550File
Jpeg.Close
'close the jpeg object
Jpeg.Close
set jpeg = nothing
If Err <> 0 Then
Response.Write "An error occurred: " & Err.Description
Else
Response.Write "
Your file was saved at " _
& "http://www.homerepairforum.com/images/uploads/" & s550File & "
" _
& "* To use this link in your post, select the following text and copy and paste it into your post.
" _
& ""
End If
Else
Response.write = "Only image (.jpg, .gif) files are allowed."
End If
End If
'put button to add to post here
else
%>
<% end if %>