Solved

Image upload not displaying new image.

Posted on 2008-10-26
6
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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