Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Image upload not displaying new image.

I'm uploading and resizing an image. On the final page the image is resized and uploaded. I want the page to also display the new resized image. Instead though it is displaying the original image. If you refresh the page the new image is displayed. If needed you can see the example, just upload an image and then on the last page (uploadthumbnail) hit refesh and you'll see the change. Can anyone tell me why this is happening and how to fix it. I've tried refreshing the page on page load, but then I lose all my request data. Here is my code:
Thanks.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<%
' create instance of AspJpeg
      Set jpeg = Server.CreateObject("Persits.Jpeg")
      
      jpeg.Open( Request("path") )
      Dim ipath
      ipath = ( Request("path") )
      response.write (ipath)
      
            ' Set resizing algorithm
      jpeg.Interpolation = Request("Interpolation")
      
      response.write ("<br />")
      
      dim iwidth
      iwidth = Request("newWidth")
      response.write (iwidth)
      
      response.write ("<br />")
      
      dim filename
      filename = Request("Filename")
      response.write (filename)
      
      ' Set new width
      jpeg.Width = Request("newWidth")
      jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth      
      
            ' Rotate if necessary. Only available in version 1.2
      If Request("Rotate") = 1 Then jpeg.RotateL
      If Request("Rotate") = 2 Then jpeg.RotateR
      
      ' create thumbnail and save it to disk
      Jpeg.Save Server.MapPath("image") & "\" & (Request("Filename") )
%>
      
      <IMG SRC="image/<% = Request("Filename")  %>">
</body>
</html>
0
elliottbenzle
Asked:
elliottbenzle
  • 2
  • 2
  • 2
2 Solutions
 
Jason C. LevineNo oneCommented:
>> Instead though it is displaying the original image. If you refresh the page the new image is displayed.

This sounds like a caching issue.

Try adding this in the head of the document:

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
0
 
RouchieCommented:
Hi

I definitely agree with Jason here.  There is also another trick in ASP to stop the page caching.  Just add this code to the start of the page.

So

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

becomes:

   <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
   <%
   Response.Expires = 0
   Response.Expiresabsolute = Now() - 1
   Response.AddHeader "pragma","no-cache"
   Response.AddHeader "cache-control","private"
   Response.CacheControl = "no-cache"
   %>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
 
elliottbenzleAuthor Commented:
That's what I thought it was too. I've tried both solutions but still the same results. Here is the new test page if you want to see what's happening:

http://www.glowfishtw.com/benzleporcelain/productadd.asp

Here is the revised code: Any other ideas?

   <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
   <%
   Response.Expires = 0
   Response.Expiresabsolute = Now() - 1
   Response.AddHeader "pragma","no-cache"
   Response.AddHeader "cache-control","private"
   Response.CacheControl = "no-cache"
   %>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<p>Product image has been resized and uploaded.</p>
<p><a href="productadd.asp">add a product </a></p>
<p><a href="productview.asp">delete/edit a product </a></p>
<p><a href="benzleupdate.asp">return to Benzle update </a></p>
<p><a href="index.asp">view Benzle Porcelain home page </a></p>
<p><br />
  <br />
 
  <%
' create instance of AspJpeg
      Set jpeg = Server.CreateObject("Persits.Jpeg")
      
      jpeg.Open( Request("path") )
      Dim ipath
      ipath = ( Request("path") )
      response.write (ipath)
      
            ' Set resizing algorithm
      jpeg.Interpolation = Request("Interpolation")
      
      response.write ("<br />")
      
      dim iwidth
      iwidth = Request("newWidth")
      response.write (iwidth)
      
      response.write ("<br />")
      
      dim filename
      filename = Request("Filename")
      response.write (filename)
      
      ' Set new width
      jpeg.Width = Request("newWidth")
      jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
      
      
            ' Rotate if necessary. Only available in version 1.2
      If Request("Rotate") = 1 Then jpeg.RotateL
      If Request("Rotate") = 2 Then jpeg.RotateR
      
      ' create thumbnail and save it to disk
      Jpeg.Save Server.MapPath("image") & "\" & (Request("Filename") )
      
%>
 
  <IMG SRC="image/<% = Request("Filename")  %>"></p>
</body>
</html>


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
RouchieCommented:
I just uploaded an image and then went through the thumbnail procedure and it worked perfectly.

For your information, the expire code that I posted should be put on the productadduploadthumb.asp page because it is on this page that we want to force the image to reload.

I would the expire code on every page just to make sure nothing is being cached.  Also clear your browser's cache before trying out your pages.
0
 
elliottbenzleAuthor Commented:
Thanks. I'm not sure which code solved the problem. That's why I'm spliting the points. Hope that's ok. Elliott
0
 
Jason C. LevineNo oneCommented:
>> Thanks. I'm not sure which code solved the problem. That's why I'm spliting the points. Hope that's ok. Elliott

That's fine.  I'm used to carrying Rouchie at this point...

;-P

I'm glad one of us fixed the problem.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now