I have imlepmented file upload with one button
i have taken one button and one file upload control and on clicking the button i am opening file upload for browsing file,
after selecting file i have to submit the form, the problem is arising when i click on submit,the file upload gets empties and i got HttpPostedFileBase null in my controller,but when i directly use file upload control(ie clicks on its browse button) its working fine
Below is my code
$(document).ready(function () {
$("#btn").click(function () {
$("#logup").click();
$("#logup").select();
return false;
});
});
<input type="button" id="btn" value="Choose file" />
<input type="file" id="logup" name="logofile" style="display:none" />
<button type="submit">Submit</button>
2nd i also wants to show file name after selecting the file, besides my btn how can i do this?
Answer To Question 1
Below is a form with two submit buttons. Note that both these submit buttons have the same name i.e “submitButton”
Now over to the Controller, the Action takes in an input parameter called string stringButton and the rest is pretty self-explanatory.
Answer To Question 2
You will be getting fileName from HttpFilePostedBase object, but since you dont want a post back, you can create an action thats return this value as
JSON