Using the idea from the article
Uploading Files in ASP.net without using the FileUpload server control, I'm trying to upload a file using hidden input type="file" by using the next:
in aspx file:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function uploadfile()
{
var ctl = document.getElementById('myFile');
ctl.click();
}
</script>
</head>
<body>
<form id="form2" runat="server" enctype="multipart/form-data">
<input type="file" id="myFile" name="myFile" style="display:none" />
<asp:Button runat="server" ID="btnUpload" Text="Upload" OnClientClick="uploadfile();" />
</form>
</body>
</html>
in code file: (i just want to make sure file is retrieved)
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpload.Click
Dim file As HttpPostedFile = Request.Files("myFile")
If file Is Nothing Then Throw New IO.FileNotFoundException
End Sub
but Post-back never occur, how to solve this problem?