Upload File Using HTML To ASPX Page

D

David Elliott

I can send a file from a TRUE HTML page to an ASPX page using the following code:

SendFile.htm
==================================
<form id="Form1" method="post" runat="server" enctype="multipart/form-data" action="AcceptFile.aspx">
<INPUT id="uploadFile" type="file" name="uploadFile" runat="server" size="1">
<br>
<br>
<INPUT id="Submit1" type="submit" value="Submit" name="Submit1">
</form>



AcceptFile.aspx.cs
===============================================
public class AcceptFile : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputFile uploadFile;

private void Page_Load(object sender, System.EventArgs e)
{
if (uploadFile.PostedFile != null)
{
System.Console.Out.WriteLine("Got File");
HttpPostedFile myFile = uploadFile.PostedFile;

uploadFile.Visible = false;
Response.Write("File: " + uploadFile.PostedFile.FileName +
"<br>File Size: " +
uploadFile.PostedFile.ContentLength);
}
}
}


The question I have is how can I get this same functionality without the use of an HtmlInputFile
control.

I have a need to display a page using HTML/javascript (Can't use .NET code) of files that are
valid to upload. When a user clicks on the buttons/links/whatever the file will be sent to the
MS .NET framework for processing.

Any help would be appreciated.


Cheers,
Dave
 
B

bruce barker

browser security prevents thus. you will need to create a signed activex
control that the user installs. (simular to going the ms update)

-- bruce (sqlwork.com)




David Elliott said:
I can send a file from a TRUE HTML page to an ASPX page using the following code:

SendFile.htm
==================================
<form id="Form1" method="post" runat="server"
enctype="multipart/form-data" action="AcceptFile.aspx">
 
D

David Elliott

I don't understand the last part. Do you mean like the Windows Update feature?

Having not worked with ActiveX before, do you know of where I could get an example
of what I am looking for?

Thanks,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top