开发者

refresh page when image content changes but image name doesn't ,php

I have an upload picture form. When the user changes the picture I overwrite the picture he already has.The picture always bears the user's name.

I use CodeIgniter, the settings a开发者_如何学Pythonre:

$config['overwrite']=TRUE;
$config['file_name']=$this->session->userdata('username');

After he uploads the picture I reload the whole page

$this->load->view('bilet/uploadform');

I have to refresh the page in order for the new pic to appear, why is this ?

Why doesn't it work the way I expect it to? (I am not using AJAX yet,I will soon)


if you save the new uploaded image name as the old one this is a caching issue , thats why you have to refresh , you can add a random generated number to the image name or in the src attribute add a random number like this for example :

http://www.mywebsite.com/image.png?number=123123

or

 http://www.mywebsite.com/image.png?number=6546587

somthing like this will prevent called cached images .

hope this will help .


yeah, its common, you have to refresh the page if you are not using some ajax magic.

To do the refresh in the CI way .

Load the URL helper .

And then

redirect('/path/to/controller', 'refresh');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜