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
|