Page 1 of 1

Clear file upload field?

Posted: Fri Aug 26, 2011 4:18 pm
by angelicodin
Was not sure if this was supposed to go into this section or the HTML section
Hey ya guys and gals. Got something I'm trying to do but can't figure it out. Basically I got a page where there is a form with various things but I noticed that if wanted to clear a field for the file upload i can't because when i click on it, it opens a new window to browse to file. How do I do a 'clear' button or a different method for doing an upload field? Or how do I make a 'browse' button? I tried to Google it but I didn't see what I was looking for, at least not with out using java and I'm sure there is some inherit function or something that might work, ~shrugs~ I have no idea. Here is what I'm doing:

Code: Select all

<form action="upload_ac.php" method="post"
enctype="multipart/form-data">
<label for="file1">Filename1:</label>
<input type="file" name="file1" id="file1" />
</form>

Re: Clear file upload field?

Posted: Fri Aug 26, 2011 5:11 pm
by social_experiment

Code: Select all

<input type="reset" value="reset" />
This will create a reset button

Re: Clear file upload field?

Posted: Fri Aug 26, 2011 5:21 pm
by angelicodin
social_experiment wrote:

Code: Select all

<input type="reset" value="reset" />
This will create a reset button
~nod nod~ but that resets all the fields right? not just the one field?

Re: Clear file upload field?

Posted: Fri Aug 26, 2011 5:44 pm
by genix2011
yes the whole form.

To reset just one field, you would have to use javascript.

Re: Clear file upload field?

Posted: Fri Aug 26, 2011 6:11 pm
by angelicodin
~cries~ ok, thanks for the help.

Re: Clear file upload field?

Posted: Fri Aug 26, 2011 9:33 pm
by califdon
In any case, it has nothing to do at all with PHP, so I have moved the topic to Javascript.

PHP executes on the server, so by the time a page is being viewed by the user (who might want to reset fields) it is far too late for PHP to do anything.