views:

25

answers:

1

I'm using js to upload files to the server using this

<form name="form" action="" method="POST" enctype="multipart/form-data" style="float:left;">
   <input id="fileToUpload" type="file" name="fileToUpload" class="input">
   <button class="button" id="buttonUpload" onClick="return ajaxFileUpload();">Upload</button>
</form> 

Instead of clicking the "Upload" button can I just return ajaxFileUpload(); after I browsed for a file and it's sent in the input?

I tried

<form name="form" action="" method="POST" enctype="multipart/form-data" style="float:left;">
    <input id="fileToUpload" type="file" name="fileToUpload" class="input" onClick="return ajaxFileUpload();">
</form> 

but it returns ajaxFileUpload(); immediately when I click the file input. Is there a way to return it only after it has some input in it?

+1  A: 

try using the onChange event instead.

Mike
Cool that sure works! :)
Cyber Junkie