Fabrizio
Fabrizio

Reputation: 69

Force Callback to reload file

I'm using a php and jQuery tool to upload and crop pictures. It works well. But i'd like to have a preview after i uploaded and croped the pictures. I got the preview, but it's the pictures befor the crop. I guess it takes the picture from any cache. When i check out the real file on the server it is croped.

Is there any idea how i can force the following function to really get the file new from the server?

That is the Code, where i put the url back to the div in the form for the preview.

    new ImgSelect( $('#imgselect_container'), {
cropComplete: function(image) {
    $('.avatar').html('<img src="scripts/imgSelect/files/' + image.name + '">');
        }
    });

Upvotes: 0

Views: 53

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337560

To force the image to be downloaded again you can append a timestamp in the querystring. Try this:

$('.avatar').html('<img src="scripts/imgSelect/files/' + image.name + '?t=' + +new Date + '">');

You could also amend the cache settings of your server.

Upvotes: 1

Related Questions