W3C home > Mailing lists > Public > www-html@w3.org > March 2003

Using <img for the browse button of a <input type=file

From: <vknab@voila.fr>
Date: Mon, 17 Mar 2003 18:01:28 +0100
Message-Id: <HBWKMG$36BFDD02F01912CB3ECF6D9A56D0FAF1@voila.fr>
To: "www-html" <www-html@w3.org>

Hello,

I red the input type file problems with default value .... and understand why there's security problem which avoid this functionality.

But, I don't understand why this does not work.
I just would use the style="display:none" of the input and a image to display the button. When I click on the picture, I launch input 
file.click() . So the popup for  choosing the file to upload appear, the user choose the file... 
But when I submit the form, I have an js error.
There's no security problem here since the user choose the file. So i don't understand why I have this error.
That 's the difference between :
  - First, the user clicks on the browse button 
  - Second, the click is fired with js ?


<form name="formPrincipal" method="post" action="resultat.php" enctype='multipart/form-data'>
 Fichier 1<input type="file" name="PHOTO1" style="display:none;">
	<input type="text" name="file">
	<img align=middle name="Parcourir" src="../images/parcourir.gif"  border="0" 
onClick="document.formPrincipal.PHOTO1.click(); document.formPrincipal.file.value=document.formPrincipal.PHOTO1.value;">
	<input type='button' value='Submit2' onclick='document.formPrincipal.submit();'>
</form>
 		


------------------------------------------

Faites un voeu et puis Voila ! www.voila.fr 
Received on Monday, 17 March 2003 12:19:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:54 GMT