Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll need to add <code>id</code> and <code>runat="server"</code> attributes like this:</p> <pre><code>&lt;input type="file" id="MyFileUpload" runat="server" /&gt; </code></pre> <p>Then, on the server-side you'll have access to the control's <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputfile.postedfile.aspx" rel="noreferrer"><code>PostedFile</code></a> property, which will give you <a href="http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.contentlength.aspx" rel="noreferrer"><code>ContentLength</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.contenttype.aspx" rel="noreferrer"><code>ContentType</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.filename.aspx" rel="noreferrer"><code>FileName</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.inputstream.aspx" rel="noreferrer"><code>InputStream</code></a> properties and a <a href="http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.saveas.aspx" rel="noreferrer"><code>SaveAs</code></a> method etc:</p> <pre><code>int contentLength = MyFileUpload.PostedFile.ContentLength; string contentType = MyFileUpload.PostedFile.ContentType; string fileName = MyFileUpload.PostedFile.FileName; MyFileUpload.PostedFile.Save(@"c:\test.tmp"); </code></pre> <p>Alternatively, you could use <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.files.aspx" rel="noreferrer"><code>Request.Files</code></a> which gives you a collection of all uploaded files:</p> <pre><code>int index = 1; foreach (HttpPostedFile postedFile in Request.Files) { int contentLength = postedFile.ContentLength; string contentType = postedFile.ContentType; string fileName = postedFile.FileName; postedFile.Save(@"c:\test" + index + ".tmp"); index++; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload