Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2005
    Location
    Bedford, UK
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    iframe refresh problem in IE

    Hi,

    Im trying to create a page for a picture framing site where users can upload images to see how they would look framed. The idea is that users will be able to change, among other things, the color of the mount used (I think what I'm calling a "mount" is called a "mat" in the US).

    The user's image is sent to "upload.php" where it is resized and overlaid with a GD-constructed gif (with a transparent aperture) which represents the mount. All this is surrounded by a picture-frame constructed from small images with CSS. "upload.php" is displayed in an iframe within the main page.

    From the main page, I'm sending variables in the url of "upload.php" (retrieved using $_GET) in order to change the color and shape of the mount. I'm also storing these variables using $_SESSION so their values are not lost when the user changes something else.

    So far, all this works fine in Firefox but it only works in IE if I manually refresh the main page.

    Here's the page for you to have a look at:
    http://www.winkleweb.org/picturegall...alworkshop.php

    Try uploading an image. On the "Mounts 1" tab there are two links which change the shape of the mount, and on the "Mounts 2" tab the small colored images are links to change the mount color. They all work without a page-refresh in Firefox, but not in IE. Any idea why?

    The upload.php file is a bit long to paste here so I've uploaded it as a text file to: http://www.winkleweb.org/picturegallery/upload.txt

    I'm new to all this so any help would be much appreciated.

    Cheers,

    Jeff

  • #2
    Regular Coder
    Join Date
    Mar 2005
    Location
    Brighton, UK
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Its because the mount is the same file for every selection (pic.gif), im assuming its generated dynamically? IE is caching the image, so every time that frame reloads it sees the same filename and just loads the one its already got rather than re requesting it from the server.

    Im guessing your going to need to change how this works anyway because if two people try to use it at the same time they will both the accessing the same pic.gif, which will be changing every time someone clicks a mount.

    There are much better ways to do this, but a quick work around is to stick a random string on the end of the image path, like this:
    Code:
    <img src="pic.gif?random=239487239472" style="border: 0;" width="400" height="307" />
    The value of random can be generated automatically by php, use rand().

    This is really just a hack though, and isnt fail safe.

    Hope that at least points you in the right direction, if you need any more help just say.

    Jack

    P.S. The upload script doesn’t accept a file if the extension is in capitals.

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i can't imagine this is a php-issue.

    by the way, in Opera, your site has the same problem. My first guess would be that it's a caching issue --> the images always have the same name, so some browsers will use the one from their cache instead of requesting a new one from the server.

    to prevent caching, the easiest workaround is to add the time() value to your filename.
    Last edited by raf; 02-15-2006 at 11:24 PM. Reason: Jak-S basically said the same, but faster (got distracted when trying it in Opera)
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    New Coder
    Join Date
    Jan 2005
    Location
    Bedford, UK
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks guys,

    I included time() in both the name of the temporary GD image and in the output file name (formerly $pic.gif) and it now works in IE. At last!!!

    However, I now have the problem of how to delete the images when they're no longer needed. I think I'll have to rethink exactly what I want to save in the $_SESSION. At the moment, all I'm saving is the file that tiles the images. I'm getting tired now though, I'll have a go in the morning.

    Thanks again,

    Jeff

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jeffnovis
    However, I now have the problem of how to delete the images when they're no longer needed.
    i think the most secure way is to run a cron every 30 minutes that requests a php page where you loop through the file-directory and that unlinks all files with a
    filemtime($file) < time()-(30*60)
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    New Coder
    Join Date
    Jan 2005
    Location
    Bedford, UK
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks raf,

    Yes, I think a cron sounds like my best bet. Or is there a way I could detect that the user had left the page so I could unlink the last file stored in their $_SESSION? Or perhaps I could resort to a "Remove your image from the server" button?

    Cheers,

    Jeff

  • #7
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jeffnovis
    Or is there a way I could detect that the user had left the page so I could unlink the last file stored in their $_SESSION?
    Not realy. If they close their browser or enter a new url, then this can't be detected by your server.
    Unless you would for instance use a frame and then set an autorefresh (with a realy small interval) on one of the pages and keep track of when they last refreshed that page. But that is realy an ugly and resource-eating way.
    Quote Originally Posted by jeffnovis
    Or perhaps I could resort to a "Remove your image from the server" button?
    You can have such a button, but in addition to that, you still need the cron to remove the images from the users that didn't hit the button.
    The button is only required if you realy have a high number of vistors and need to remove the space asap. That the images unnescecarely take up some space for maximum 30 minutes shouldn't have any impact on your servers performance.

    If you realy have a hight number of isitors, then it would be best to define a maximum amount of space for all images, and to check if this wasn't reached before uploading a new immage + to run your cron more frequently.
    Last edited by raf; 02-16-2006 at 02:21 PM.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #8
    New Coder
    Join Date
    Jan 2005
    Location
    Bedford, UK
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi raf,

    I'm doing this for my sister's website. She has high hopes for it, but I don't know how popular it will be. I think a cron run every 30 minutes as you suggest would do the job.

    Thanks for your help,

    Jeff


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •