Clear file upload field?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Clear file upload field?

Post 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>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Clear file upload field?

Post by social_experiment »

Code: Select all

<input type="reset" value="reset" />
This will create a reset button
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Re: Clear file upload field?

Post 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?
genix2011
Forum Commoner
Posts: 74
Joined: Tue Aug 02, 2011 4:00 pm

Re: Clear file upload field?

Post by genix2011 »

yes the whole form.

To reset just one field, you would have to use javascript.
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Re: Clear file upload field?

Post by angelicodin »

~cries~ ok, thanks for the help.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Clear file upload field?

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