user1808537
user1808537

Reputation: 19

how to block uploading same image after refresh the page?

im using verot.net's upload class and i almost finished my image upload project. i just couldnt manage to do this uploading same image over and over thing. here is a little code.

if ($upload -> uploaded){

    $rand = uniqid(true);
    $upload -> file_new_name_body = $rand;


$upload -> Process("upload");

    if ($upload -> processed){

i have to rename it with random but if i do that ,everytime my when my upload.php refreshed,it renames it randomly and uploads to the server. how can i block this ?

Upvotes: 0

Views: 115

Answers (1)

John Conde
John Conde

Reputation: 219804

Pages that are loaded via POST will cause the browser to ask the user to resubmit the information to view the page resulting in the actions performed by that page happening again. If the pages is requested via GET and has variables in the querystring the same thing happens but silently (without the user being prompted to d it again).

The best to work around this is to use the POST/REDIRECT/GET pattern.

Upvotes: 1

Related Questions