Jump to content

[SOLVED] removing files


shadiadiph

Recommended Posts

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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.