Solved

Image upload not displaying new image.

Posted on 2008-10-26
6
191 Views
Last Modified: 2012-05-05
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
Comment
Question by:elliottbenzle
  • 2
  • 2
  • 2
6 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 250 total points
ID: 22810313
>> 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
 
LVL 25

Assisted Solution

by:Rouchie
Rouchie earned 250 total points
ID: 22810691
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
 
LVL 4

Author Comment

by:elliottbenzle
ID: 22813134
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 25

Expert Comment

by:Rouchie
ID: 22813251
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
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 31510200
Thanks. I'm not sure which code solved the problem. That's why I'm spliting the points. Hope that's ok. Elliott
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 22815855
>> 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now