shadiadiph Posted May 24, 2009 Share Posted May 24, 2009 i have a file upload form once submitted it works fine inserts picture names to the database and saves them to file only problem is if i refresh the page it inserts them again?? how can i reset them how can i clear all these once they have been posted once? $fileatt_name = $_FILES['fileatt']['name']; $attachment1 = stripslashes($fileatt_name[0]); $attachment2 = stripslashes($fileatt_name[1]); $attachment3 = stripslashes($fileatt_name[2]); $attachment4 = stripslashes($fileatt_name[3]); $filedes1 = stripslashes($_POST["desfileatt"][0]); $filedes2 = stripslashes($_POST["desfileatt"][1]); $filedes3 = stripslashes($_POST["desfileatt"][2]); $filedes4 = stripslashes($_POST["desfileatt"][3]); Link to comment https://forums.phpfreaks.com/topic/159460-solved-removing-files/ Share on other sites More sharing options...
papaface Posted May 24, 2009 Share Posted May 24, 2009 You could try: $_FILES = array(); $_POST = array(); But for a fool proof way, I think you may have to generate a value in a hidden field which is unique. When someone uploads something have that value inserted into the database IF its not already in the table. If it is then it is a duplicate (i.e the person refreshed the page) and have the script exit or produce an error. Link to comment https://forums.phpfreaks.com/topic/159460-solved-removing-files/#findComment-841145 Share on other sites More sharing options...
shadiadiph Posted May 24, 2009 Author Share Posted May 24, 2009 m thank you but that did not work isn't there anyway of destroying a post value once it has been posted? I tried to unset all the values e.g unset($attachment1); but that didn't work either? Link to comment https://forums.phpfreaks.com/topic/159460-solved-removing-files/#findComment-841151 Share on other sites More sharing options...
Mark Baker Posted May 24, 2009 Share Posted May 24, 2009 You can't destroy the post value because it's being resubmitted by the browser and rerunning the script. What you want to do is set a cookie when running the script the first time... then, if the user refreshes, you test to see if the cookie is already set and if it is, you don't process the request again Link to comment https://forums.phpfreaks.com/topic/159460-solved-removing-files/#findComment-841153 Share on other sites More sharing options...
shadiadiph Posted May 24, 2009 Author Share Posted May 24, 2009 problem with that is the user can upload up to 20 images 4 at a time using the same submit script Link to comment https://forums.phpfreaks.com/topic/159460-solved-removing-files/#findComment-841155 Share on other sites More sharing options...
shadiadiph Posted May 24, 2009 Author Share Posted May 24, 2009 ok i wrote a code to check if the file exists already Link to comment https://forums.phpfreaks.com/topic/159460-solved-removing-files/#findComment-841172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.