Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2010, 01:43 PM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default asp jpeg/asp upload

Hi there

I had asp jpeg and asp upload working perfectly until I was told we were going to switch hosts - the only difference between the 2 hosts was to use SaveVirtual as they only support virtual paths which was fine, however.....

Now after a couple of changes to the code to accommodate this my image is not being uploaded from the edit page - it takes the name of the image i.e sml_myfilename.jpg and med_myfilename.jpg but the image doens't get uploaded - I have no idea why and was hoping someone could help me - my code is below:

if UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" then



'-----------------------------------------------
' don't output anything until i say so
'-----------------------------------------------
response.buffer = true

'-----------------------------------------------
' Create an instance of AspUpload object
'-----------------------------------------------
Set Upload = Server.CreateObject("Persits.Upload")

Set UploadProgress = Server.CreateObject("Persits.Upload")
Upload.ProgressID = Request.QueryString("PID")

'--------------------------------------------------------------------
' Capture uploaded file. Save returns the number of files uploaded
'--------------------------------------------------------------------


Upload.SaveVirtual "temp"

strOriginalImageName = ""

Set objFile = Upload.Files(1)

if intCount > 0 then


If UCase(objFile.ImageType) <> "JPG" Then
%>
<script language="JavaScript">
window.alert("The Selected Image has to be a JPEG Image!");
history.go(-1);
</script>
<%
objFile.Delete
Set objFile = Nothing
Set Upload = Nothing

con.close
set con = Nothing

Response.End()

end if

strSQL = "EXEC sp_CatImage_Check '" & Replace(objFile.FileName, "'", "''") & "', " & Upload.Form("id")
Set rsCheck = con.execute(strSQL)

rsCheck.MoveFirst

intCheckCount = CInt(rsCheck(0))

Set rsCheck = Nothing

If intCheckCount > 0 Then
%>
<script language="JavaScript">
window.alert("An image with that name already exists!");
history.go(-1);
</script>
<%
objFile.Delete
Set objFile = Nothing
Set Upload = Nothing

con.close
set con = Nothing

Response.End()

end if

if LCase(objFile.FileName) <> LCase(strImageName) then
strOriginalImageName = strImageName
end if

strOriginalImagePath = objFile.Path

objFile.SaveAsVirtual("/images/category") & "\" & objFile.FileName


Set jpeg = Server.CreateObject("Persits.Jpeg")

jpeg.Open(Application("Image_Folder_Cats") & "\" & objFile.FileName)

theWidthRatio = Application("Image_sml_width") / jpeg.OriginalWidth

Set jpeg = Server.CreateObject("Persits.Jpeg")

jpeg.Open(Application("Image_Folder_Cats") & "\" & objFile.FileName)

theSmlWidthRatio = Application("Image_sml_width") / jpeg.OriginalWidth

if CDbl(theSmlWidthRatio) < 1 then
jpeg.Width = Application("Image_sml_width")
jpeg.Height = CInt(jpeg.OriginalHeight * theSmlWidthRatio)
jpeg.Save(Application("Image_Folder_Cats") & "\sml_" & objFile.FileName)
else
jpeg.Save(Application("Image_Folder_Cats") & "\sml_" & objFile.FileName)
end if

theBigWidthRatio = Application("Image_med_width") / jpeg.OriginalWidth

if CDbl(theBigWidthRatio) < 1 then
jpeg.Width = Application("Image_med_width")
jpeg.Height = CInt(jpeg.OriginalHeight * theBigWidthRatio)
jpeg.Save(Application("Image_Folder_Cats") & "\med_" & objFile.FileName)
else
jpeg.Save(Application("Image_Folder_Cats") & "\med_" & objFile.FileName)
end if

set jpeg = nothing

strImageName = objFile.FileName
strImageNameSml = "sml_" & objFile.FileName
strImageNameMed = "med_" & objFile.FileName

Set fso = CreateObject("Scripting.FileSystemObject")

fso.DeleteFile(strOriginalImagePath)

Set fso = Nothing




strSQL = "EXEC sp_Cat_Update " & Upload.Form("id") & " , '" & Upload.Form("txtCategory") & "' , '" & Replace(Upload.Form("txtSequence"), "'", "''") & "' , '" & Replace(strImageNameSml, "'", "''") & "', '" & Replace(strImageNameMed, "'", "''") & "'"

'response.Write(strsql)
'response.End()

con.execute strSQL



else



strImageName = objFile.FileName
strImageNameSml = "sml_" & objFile.FileName
strImageNameMed = "med_" & objFile.FileName



strSQL = "EXEC sp_Cat_Update " & Upload.Form("id") & " , '" & Upload.Form("txtCategory") & "' , '" & Replace(Upload.Form("txtSequence"), "'", "''") & "' , '" & Replace(strImageNameSml, "'", "''") & "', '" & Replace(strImageNameMed, "'", "''") & "'"

'response.Write(strsql)
'response.End()

con.execute strSQL

end if


Set objFile = Nothing

con.close
set con = Nothing






%>
<script language="javascript">
window.opener.history.go(0);
window.close();
</script>
<%

set upload = nothing

response.End()

end if
%>

thanks alot for any help
 
Old March 9th, 2010, 05:32 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You have this:
Code:
if intCount > 0 then
but you never assign any value to the variable, so it will always be seen as zero.
 
Old March 10th, 2010, 05:02 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default thanks

I see - thanks very much.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Upload Error saurabhj Classic ASP Professional 1 May 5th, 2007 12:53 AM
ASP Smart Upload arabuafef Classic ASP Basics 0 December 24th, 2006 05:48 AM
ASP Upload vin_0x1 Classic ASP Databases 1 June 24th, 2006 05:35 PM
ASP Upload nabeeljohn Classic ASP Professional 1 November 28th, 2005 05:59 AM
upload asp to the web hastikeyvan Dreamweaver (all versions) 27 July 31st, 2005 05:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.