Welcome Guest, Not a member yet? Register   Sign In
When I refresh the page it duplicates a image
#1

Hello everybody. I am a new user of CodeIgniter and I am having a problem after uploading a image. 
I need to upload a file and everything is fine. After I upload the file I get redirected to a success page. But if I refresh (F5) this page, the image is duplicated in the folder. As I am renaming it, it never will get the same name, so I can not "override" the image. I have already tried to "unset($imageUploaded)" after I upload it, but it did not worked.
Anyone has any idea abut how to solve this problem? 
Thanks, Alfredinho.
Reply
#2

on my webs , only admin can log in so it should be fairly foolproof ...however
i use a form to upload an image

i get data on image name such as ..
Code:
$file = $this->request->getFile('userfile');
                   $name= $file->getName();
                $tempfile = $file->getTempName();
                $slug= url_title($cleanTitle);

but before any image can be uploaded i do a check on directory where irt would go, using variations on:

Code:
file_exists(nameOfImage)

So if there was refresh or any circumstance where there was an attempt to load same image, it would feedback "image already exists" so it would do that before
any image was uploaded
I use Arch Linux by the way 

CMS in Action
Reply




Theme © iAndrew 2016 - Forum software by © MyBB