Solved

Image upload not displaying new image.

Posted on 2008-10-26
6
199 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
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.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

630 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