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
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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.