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
Solved

Image upload not displaying new image.

Posted on 2008-10-26
6
195 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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