0
votes

this is a normal html method of attaching a file.

form enctype=<"multipart/form-data" action="savefile.php" method="POST" name="myform">

Send this file: input name="myfile" type="file" onchange="document.forms['myform'].submit() ;"

/form>

savefile.php

move_uploaded_file($_FILES["myfile"]["tmp_name"],

"upload/" . $_FILES["myfile"]["name"]);

echo "Stored in: " . "upload/" . $_FILES["myfile"]["name"];

it works perfectly, my difficulty is that when i attach a file and it sends, when i refresh the page, the file i attached still remains in the attachment, how can i clear it so it shows "No chosen file" thnks

2

2 Answers

1
votes

You need to redirect the user with

 header("Location: yourpage.php");

Also, submitting your form that way might not work on every browser.

0
votes
<input name="myfile" type="file" onchange="document.forms['myform'].submit() ;" />

And JAVASCRIPT

var myInput = $("#input[name='myfile']");       

function resetInput(){       
    myInput.replaceWith( myInput.val('').clone( true ) );
};

Call resetInput() after the upload.

Ripped and adapted From this thread