Modifying file upload button style

  • Thread starter Thread starter RJN
  • Start date Start date
R

RJN

Hi

I'm using the html input type=file for uploading a file. I'm unable to
change the style of "Browse" button that appears alongside the text box.

So what I tried is I created one more input type = button , aligned the
style of this to overlap that of the "Browse" button of file upload and
using the javascript called the click event of file upload from the
click event of button.

<!-- Input type File -->
<INPUT id="filUpload" name ="filUpload" style=" LEFT: 250px; WIDTH:
500px; POSITION: absolute; TOP: 100px; HEIGHT: 22px" type="file"
runat="server">

<!--Button for triggering the file upload-->
<Div id="BrowseButton">
<input type = "button" id="btnBrowse" value="Browse..." style="Z-INDEX:
102; LEFT: 669px; WIDTH: 82px; POSITION: absolute; TOP: 120px; HEIGHT:
24px" class = "myclass" onclick = "filUpload.click();return false;"
runat="server">
</Div>

<!--Button for Submitting the page for uploading file-->
<asp:button id="btnUpload" runat="server" Width="120" Text="Upload File"
Height="24"></asp:button>

on clicking the button(id="btnBrowse") , opens the file selection
window. However on selecting the file and submitting the page by
clicking on "btnUpload" , upload doesn't happen. But if I select the
file by clicking on "filUpload" button, upload works properly.
Simulating the click event of "filUpload" only selects the file but does
not upload the file.

Any solution please?

Regards

RJN
 
What if you don't return false from the click event ? Also check out the
HTML code to see if you have the proper enctype on the form client-side ? If
not set it server side and see if the HTML code looks good. (I saw once
someone for which it worked without it which make me think some javascript
could set it when needed and this code could perhaps breaks when the button
is not clicked directly).

Patrice
 
Hi.
I think its an IE security measure.
IE clears the content of the file input component prior to the submit event.
You'll notice that you have to click twice.
1st time IE clears the file content.
2nd time the form is submitted.
Unfortunately i don't know of any work around.
Sharon.
 
Back
Top