a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
446 lines
36 KiB
XML
446 lines
36 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<Type Name="FileUpload" FullName="System.Web.UI.WebControls.FileUpload">
|
||
<TypeSignature Language="C#" Value="public class FileUpload : System.Web.UI.WebControls.WebControl" />
|
||
<AssemblyInfo>
|
||
<AssemblyName>System.Web</AssemblyName>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
<Base>
|
||
<BaseTypeName>System.Web.UI.WebControls.WebControl</BaseTypeName>
|
||
</Base>
|
||
<Interfaces />
|
||
<Attributes>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Designer("DesignerBaseTypeNameSystem.ComponentModel.Design.IDesignerDesignerTypeNameSystem.Web.UI.Design.WebControls.PreviewControlDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.Web.UI.ValidationProperty("FileName")</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.Web.UI.ControlValueProperty("FileBytes")</AttributeName>
|
||
</Attribute>
|
||
</Attributes>
|
||
<Docs>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>In this topic:</para>
|
||
<list type="bullet">
|
||
<item>
|
||
<para>
|
||
<format type="text/html">
|
||
<a href="">Introduction</a>
|
||
</format>
|
||
</para>
|
||
</item>
|
||
<item>
|
||
<para>
|
||
<format type="text/html">
|
||
<a href="#saving_uploaded_files">Saving Uploaded Files</a>
|
||
</format>
|
||
</para>
|
||
</item>
|
||
<item>
|
||
<para>
|
||
<format type="text/html">
|
||
<a href="#security_considerations">Security Considerations</a>
|
||
</format>
|
||
</para>
|
||
</item>
|
||
<item>
|
||
<para>
|
||
<format type="text/html">
|
||
<a href="#memory_limitations">Memory Limitations</a>
|
||
</format>
|
||
</para>
|
||
</item>
|
||
<item>
|
||
<para>
|
||
<format type="text/html">
|
||
<a href="#using_the_FileUpload_Control_with_the_UpdatePanel_control">Using the FileUpload Control with the UpdatePanel Control</a>
|
||
</format>
|
||
</para>
|
||
</item>
|
||
<item>
|
||
<para>
|
||
<format type="text/html">
|
||
<a href="#DeclarativeSyntax">Declarative Syntax</a>
|
||
</format>
|
||
</para>
|
||
</item>
|
||
</list>
|
||
<format type="text/html">
|
||
<a href="#Introduction" />
|
||
</format>
|
||
<format type="text/html">
|
||
<h2>Introduction</h2>
|
||
</format>
|
||
<para>The <see cref="T:System.Web.UI.WebControls.FileUpload" /> class displays a text box control and a browse button that enable users to select a file on the client and upload it to the Web server. The user specifies the file to upload by entering the full path of the file on the local computer (for example, <userInputLocalizable>C:\MyFiles\TestFile.txt</userInputLocalizable>) in the text box of the control. Alternately, the user can select the file by clicking the <ui>Browse</ui> button, and then locating it in the <ui>Choose File</ui> dialog box.</para>
|
||
<para>Use the <see cref="P:System.Web.UI.WebControls.FileUpload.FileName" /> property to get the name of a file on a client to upload by using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control. The file name that this property returns does not include the path of the file on the client.</para>
|
||
<para>The <see cref="P:System.Web.UI.WebControls.FileUpload.FileContent" /> property gets a <see cref="T:System.IO.Stream" /> object that points to a file to upload. Use this property to access the contents of the file as bytes. For example, you can use the <see cref="T:System.IO.Stream" /> object that is returned by the <see cref="P:System.Web.UI.WebControls.FileUpload.FileContent" /> property to read the contents of the file as bytes and store them in a byte array. Alternatively, you can use the <see cref="P:System.Web.UI.WebControls.FileUpload.FileBytes" /> property to retrieve all the bytes in the file.</para>
|
||
<para>The <see cref="P:System.Web.UI.WebControls.FileUpload.PostedFile" /> property gets the underlying <see cref="T:System.Web.HttpPostedFile" /> object for the file to upload. You can use this property to access additional properties on the file. The <see cref="P:System.Web.HttpPostedFile.ContentLength" /> property gets the length of the file. The <see cref="P:System.Web.HttpPostedFile.ContentType" /> property gets the MIME content type of the file. In addition, you can use the <see cref="P:System.Web.UI.WebControls.FileUpload.PostedFile" /> property to access the <see cref="P:System.Web.HttpPostedFile.FileName" /> property, the <see cref="P:System.Web.HttpPostedFile.InputStream" /> property, and the <see cref="M:System.Web.HttpPostedFile.SaveAs(System.String)" /> method. However, the same functionality is provided by the <see cref="P:System.Web.UI.WebControls.FileUpload.FileName" /> property, the <see cref="P:System.Web.UI.WebControls.FileUpload.FileContent" /> property, and the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method.</para>
|
||
<format type="text/html">
|
||
<a href="#saving_uploaded_files" />
|
||
</format>
|
||
<format type="text/html">
|
||
<h2>Saving Uploaded Files</h2>
|
||
</format>
|
||
<para>The <see cref="T:System.Web.UI.WebControls.FileUpload" /> control does not automatically save a file to the server after the user selects the file to upload. You must explicitly provide a control or mechanism to allow the user to submit the specified file. For example, you can provide a button that the user clicks to upload the file. The code that you write to save the specified file should call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method, which saves the contents of a file to a specified path on the server. Typically, the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method is called in an event-handling method for an event that raises a post back to the server. For example, if you provide a button to submit a file, you could include the code to save the file inside the event-handling method for the click event.</para>
|
||
<para>Before calling the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method to save the file to the server, use the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> property to verify that the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control contains a file. If the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> returns true, call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method. If it returns false, display a message to the user indicating that the control does not contain a file. Do not check the <see cref="P:System.Web.UI.WebControls.FileUpload.PostedFile" /> property to determine whether a file to upload exists because, by default, this property contains 0Â bytes. As a result, even when the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control is blank, the <see cref="P:System.Web.UI.WebControls.FileUpload.PostedFile" /> property returns a non-null value.</para>
|
||
<format type="text/html">
|
||
<a href="#security_considerations" />
|
||
</format>
|
||
<format type="text/html">
|
||
<h2>Security Considerations</h2>
|
||
</format>
|
||
<para>When you call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method, you must specify the full path of the directory in which to save the uploaded file. If you do not explicitly specify a path in your application code, an exception is thrown when a user attempts to upload a file. This behavior helps keep the files on the server secure by preventing users from being able to write to arbitrary locations in your application's directory structure, as well as preventing access to sensitive root directories.</para>
|
||
<para>The <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method writes the uploaded file to the specified directory. Therefore, the ASP.NET application must have write access to the directory on the server. There are two ways that the application can get write access. You can explicitly grant write access to the account under which the application is running, in the directory in which the uploaded files will be saved. Alternatively, you can increase the level of trust that is granted to the ASP.NET application. To get write access to the executing directory for the application, the application must be granted the <see cref="T:System.Web.AspNetHostingPermission" /> object with the trust level set to the <see cref="F:System.Web.AspNetHostingPermissionLevel.Medium" /> value. Increasing the level of trust increases the application's access to resources on the server. Note that this is not a secure approach, because a malicious user who gains control of your application will also be able to run under this higher level of trust. It is a best practice to run an ASP.NET application in the context of a user with the minimum privileges that are required for the application to run. For more information about security in ASP.NET applications, see <format type="text/html"><a href="3eeeee9e-b09f-4c7f-8ce5-d9ca1f9322ad">Basic Security Practices for Web Applications</a></format> and <format type="text/html"><a href="F897C794-10D3-414C-86B7-59B66564BBF1">ASP.NET Trust Levels and Policy Files</a></format>.</para>
|
||
<format type="text/html">
|
||
<a href="#memory_limitations" />
|
||
</format>
|
||
<format type="text/html">
|
||
<h2>Memory Limitations</h2>
|
||
</format>
|
||
<para>One way to guard against denial of service attacks is to limit the size of the files that can be uploaded by using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control. You should set a size limit that is appropriate for the types of files that you expect to be uploaded. The default size limit is 4096Â kilobytes (KB), or 4Â megabytes (MB). You can allow larger files to be uploaded by setting the maxRequestLength attribute of the <format type="text/html"><a href="E9B81350-8AAF-47CC-9843-5F7D0C59F369">httpRuntime</a></format> element. To increase the maximum allowable file size for the entire application, set the maxRequestLength attribute in the Web.config file. To increase the maximum allowable file size for a specified page, set the maxRequestLength attribute inside the location element in Web.config. For an example, see <format type="text/html"><a href="922EF7D5-DA38-4661-B1C6-5B9E5CEDA1D5">location Element (ASP.NET Settings Schema)</a></format>.</para>
|
||
<para>When uploading large files, a user might also receive the following error message:</para>
|
||
<para>aspnet_wp.exe (PID: 1520) was recycled because memory consumption exceeded 460 MB (60 percent of available RAM).</para>
|
||
<para>If your users encounter this error message, increase the value of the memoryLimit attribute in the <format type="text/html"><a href="4B8FE20E-74C8-4566-B72C-CE5F83C8E32D">processModel</a></format> of element the Web.config file for the application. The memoryLimit attribute specifies the maximum amount of memory that a worker process can use. If the worker process exceeds the memoryLimit amount, a new process is created to replace it, and all current requests are reassigned to the new process.</para>
|
||
<para>To control whether the file to upload is temporarily stored in memory or on the server while the request is being processed, set the requestLengthDiskThreshold attribute of the <format type="text/html"><a href="E9B81350-8AAF-47CC-9843-5F7D0C59F369">httpRuntime</a></format> element. This attribute enables you to manage the size of the input stream buffer. The default is 256Â bytes. The value that you specify should not exceed the value that you specify for the maxRequestLength attribute.</para>
|
||
<format type="text/html">
|
||
<a href="#using_the_FileUpload_Control_with_the_UpdatePanel_control" />
|
||
</format>
|
||
<format type="text/html">
|
||
<h2>Using the FileUpload Control with the UpdatePanel Control</h2>
|
||
</format>
|
||
<para>The <see cref="T:System.Web.UI.WebControls.FileUpload" /> control is designed to be used only in postback scenarios and not in asynchronous postback scenarios during partial-page rendering. When you use a <see cref="T:System.Web.UI.WebControls.FileUpload" /> control inside an <see cref="T:System.Web.UI.UpdatePanel" /> control, the file must be uploaded by using a control that is a <see cref="T:System.Web.UI.PostBackTrigger" /> object for the panel. <see cref="T:System.Web.UI.UpdatePanel" /> controls are used to update selected regions of a page instead of updating the whole page with a postback. For more information, see <format type="text/html"><a href="29a2265d-9674-4c19-b70e-e5560ee9689a">UpdatePanel Control Overview</a></format> and <format type="text/html"><a href="5c12736d-d9e9-464a-9388-3fe0f9f49e49">Partial-Page Rendering Overview</a></format>.</para>
|
||
<format type="text/html">
|
||
<a href="#DeclarativeSyntax" />
|
||
</format>
|
||
<format type="text/html">
|
||
<h2>Declarative Syntax</h2>
|
||
</format>
|
||
<code><asp:FileUpload
|
||
    AccessKey="string"
|
||
    BackColor="color name|#dddddd"
|
||
    BorderColor="color name|#dddddd"
|
||
    BorderStyle="<codeFeaturedElement>NotSet</codeFeaturedElement>|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
|
||
Inset|Outset"
|
||
    BorderWidth="size"
|
||
    CssClass="string"
|
||
    Enabled="<codeFeaturedElement>True</codeFeaturedElement>|False"
|
||
    EnableTheming="<codeFeaturedElement>True</codeFeaturedElement>|False"
|
||
    EnableViewState="<codeFeaturedElement>True</codeFeaturedElement>|False"
|
||
    Font-Bold="True|<codeFeaturedElement>False</codeFeaturedElement>"
|
||
    Font-Italic="True|<codeFeaturedElement>False</codeFeaturedElement>"
|
||
    Font-Names="string"
|
||
    Font-Overline="True|<codeFeaturedElement>False</codeFeaturedElement>"
|
||
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
|
||
Large|X-Large|XX-Large"
|
||
    Font-Strikeout="True|<codeFeaturedElement>False</codeFeaturedElement>"
|
||
    Font-Underline="True|<codeFeaturedElement>False</codeFeaturedElement>"
|
||
    ForeColor="color name|#dddddd"
|
||
    Height="size"
|
||
    ID="string"
|
||
    OnDataBinding="DataBinding event handler"
|
||
    OnDisposed="Disposed event handler"
|
||
    OnInit="Init event handler"
|
||
    OnLoad="Load event handler"
|
||
    OnPreRender="PreRender event handler"
|
||
    OnUnload="Unload event handler"
|
||
    runat="server"
|
||
    SkinID="string"
|
||
    Style="string"
|
||
    TabIndex="integer"
|
||
    ToolTip="string"
|
||
    Visible="<codeFeaturedElement>True</codeFeaturedElement>|False"
|
||
    Width="size"
|
||
/></code>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Displays a text box control and a browse button that enable users to select a file to upload to the server.</para>
|
||
</summary>
|
||
</Docs>
|
||
<Members>
|
||
<Member MemberName=".ctor">
|
||
<MemberSignature Language="C#" Value="public FileUpload ();" />
|
||
<MemberType>Constructor</MemberType>
|
||
<Parameters />
|
||
<Docs>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Use the <see cref="M:System.Web.UI.WebControls.FileUpload.#ctor" /> constructor to initialize a new instance of the <see cref="T:System.Web.UI.WebControls.FileUpload" /> class. The <see cref="T:System.Web.UI.WebControls.FileUpload" /> control does not automatically save a file to the server after the user selects the file to upload. You must explicitly provide a control or mechanism to allow the user to submit the specified file. For example, you can provide a button that the user clicks to upload the file.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.FileUpload" /> class.</para>
|
||
</summary>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="AddAttributesToRender">
|
||
<MemberSignature Language="C#" Value="protected override void AddAttributesToRender (System.Web.UI.HtmlTextWriter writer);" />
|
||
<MemberType>Method</MemberType>
|
||
<ReturnValue>
|
||
<ReturnType>System.Void</ReturnType>
|
||
</ReturnValue>
|
||
<Parameters>
|
||
<Parameter Name="writer" Type="System.Web.UI.HtmlTextWriter" />
|
||
</Parameters>
|
||
<Docs>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="M:System.Web.UI.WebControls.FileUpload.AddAttributesToRender(System.Web.UI.HtmlTextWriter)" /> method is primarily used by control developers to insert the appropriate attributes and styles to the <see cref="T:System.Web.UI.HtmlTextWriter" /> output stream for a <see cref="T:System.Web.UI.WebControls.FileUpload" /> control. The <see cref="M:System.Web.UI.WebControls.FileUpload.AddAttributesToRender(System.Web.UI.HtmlTextWriter)" /> method overrides the <see cref="M:System.Web.UI.WebControls.WebControl.AddAttributesToRender(System.Web.UI.HtmlTextWriter)" /> method.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Adds the HTML attributes and styles of a <see cref="T:System.Web.UI.WebControls.FileUpload" /> control to render to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object.</para>
|
||
</summary>
|
||
<param name="writer">
|
||
<attribution license="cc4" from="Microsoft" modified="false" />An <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="FileBytes">
|
||
<MemberSignature Language="C#" Value="public byte[] FileBytes { get; }" />
|
||
<MemberType>Property</MemberType>
|
||
<Attributes>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Bindable(true, System.ComponentModel.BindingDirection.OneWay)</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)</AttributeName>
|
||
</Attribute>
|
||
</Attributes>
|
||
<ReturnValue>
|
||
<ReturnType>System.Byte[]</ReturnType>
|
||
</ReturnValue>
|
||
<Docs>
|
||
<value>To be added.</value>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="T:System.Web.UI.WebControls.FileUpload" /> control does not automatically read the file from the client. You must explicitly provide a control or mechanism to allow the user to submit the specified file. For example, you can provide a button that the user can click to upload the file. The code that you write to save the specified file could call the <see cref="P:System.Web.UI.WebControls.FileUpload.FileBytes" /> property, which returns the contents of the file.</para>
|
||
<para>Before calling the <see cref="P:System.Web.UI.WebControls.FileUpload.FileBytes" /> property, you should use the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> property to verify that the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control contains a file to upload. If the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> returns true, call the <see cref="P:System.Web.UI.WebControls.FileUpload.FileBytes" /> property. If it returns false, display a message to the user indicating that the control does not contain a file. If you do not provide error-handling code to verify that a file exists, an attempt to save a nonexistent file throws an <see cref="T:System.Web.HttpException" /> exception.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Gets an array of the bytes in a file that is specified by using a <see cref="T:System.Web.UI.WebControls.FileUpload" /> control.</para>
|
||
</summary>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="FileContent">
|
||
<MemberSignature Language="C#" Value="public System.IO.Stream FileContent { get; }" />
|
||
<MemberType>Property</MemberType>
|
||
<Attributes>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
|
||
</Attribute>
|
||
</Attributes>
|
||
<ReturnValue>
|
||
<ReturnType>System.IO.Stream</ReturnType>
|
||
</ReturnValue>
|
||
<Docs>
|
||
<value>To be added.</value>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="P:System.Web.UI.WebControls.FileUpload.FileContent" /> property gets a <see cref="T:System.IO.Stream" /> object that points to a file to upload by using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control. Use the <see cref="P:System.Web.UI.WebControls.FileUpload.FileContent" /> property to access the contents of the file. For example, you can use the <see cref="T:System.IO.Stream" /> object that is returned by this property to read the contents of the file as bytes and store them in a byte array.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Gets a <see cref="T:System.IO.Stream" /> object that points to a file to upload using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control.</para>
|
||
</summary>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="FileName">
|
||
<MemberSignature Language="C#" Value="public string FileName { get; }" />
|
||
<MemberType>Property</MemberType>
|
||
<Attributes>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
|
||
</Attribute>
|
||
</Attributes>
|
||
<ReturnValue>
|
||
<ReturnType>System.String</ReturnType>
|
||
</ReturnValue>
|
||
<Docs>
|
||
<value>To be added.</value>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Gets the name of a file on a client to upload using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control. The file name that the <see cref="P:System.Web.UI.WebControls.FileUpload.FileName" /> property returns does not include the path of the file on the client.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Gets the name of a file on a client to upload using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control.</para>
|
||
</summary>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="HasFile">
|
||
<MemberSignature Language="C#" Value="public bool HasFile { get; }" />
|
||
<MemberType>Property</MemberType>
|
||
<Attributes>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
|
||
</Attribute>
|
||
</Attributes>
|
||
<ReturnValue>
|
||
<ReturnType>System.Boolean</ReturnType>
|
||
</ReturnValue>
|
||
<Docs>
|
||
<value>To be added.</value>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> property gets a value indicating whether the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control contains a file to upload. Use this property to verify that a file to upload exists before performing operations on the file. For example, before calling the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method to save the file to disk, use the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> property to verify that the file exists. If <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> returns true, call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method. If it returns false, display a message to the user indicating that the control does not contain a file.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Gets a value indicating whether the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control contains a file.</para>
|
||
</summary>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="OnPreRender">
|
||
<MemberSignature Language="C#" Value="protected override void OnPreRender (EventArgs e);" />
|
||
<MemberType>Method</MemberType>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
<ReturnValue>
|
||
<ReturnType>System.Void</ReturnType>
|
||
</ReturnValue>
|
||
<Parameters>
|
||
<Parameter Name="e" Type="System.EventArgs" />
|
||
</Parameters>
|
||
<Docs>
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="M:System.Web.UI.WebControls.FileUpload.OnPreRender(System.EventArgs)" /> method notifies the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control to perform any necessary pre-rendering steps before saving view state and rendering content.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Raises the <see cref="E:System.Web.UI.Control.PreRender" /> event for the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control.</para>
|
||
</summary>
|
||
<param name="e">
|
||
<attribution license="cc4" from="Microsoft" modified="false" />An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
|
||
</Docs>
|
||
</Member>
|
||
<Member MemberName="PostedFile">
|
||
<MemberSignature Language="C#" Value="public System.Web.HttpPostedFile PostedFile { get; }" />
|
||
<MemberType>Property</MemberType>
|
||
<Attributes>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)</AttributeName>
|
||
</Attribute>
|
||
<Attribute>
|
||
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
|
||
</Attribute>
|
||
</Attributes>
|
||
<ReturnValue>
|
||
<ReturnType>System.Web.HttpPostedFile</ReturnType>
|
||
</ReturnValue>
|
||
<Docs>
|
||
<value>To be added.</value>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="P:System.Web.UI.WebControls.FileUpload.PostedFile" /> property gets the underlying <see cref="T:System.Web.HttpPostedFile" /> object for a file that is uploaded by using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control. Use this property to access additional properties on the uploaded file.</para>
|
||
<para>You can use the <see cref="P:System.Web.HttpPostedFile.ContentLength" /> property to get the length of the file. You can use the <see cref="P:System.Web.HttpPostedFile.ContentType" /> property to get the MIME content type of the file. In addition, you can use the <see cref="P:System.Web.UI.WebControls.FileUpload.PostedFile" /> property to access the <see cref="P:System.Web.HttpPostedFile.FileName" /> property, the <see cref="P:System.Web.HttpPostedFile.InputStream" /> property, and the <see cref="M:System.Web.HttpPostedFile.SaveAs(System.String)" /> method. However, the same functionality is provided by the <see cref="P:System.Web.UI.WebControls.FileUpload.FileName" /> property, the <see cref="P:System.Web.UI.WebControls.FileUpload.FileContent" /> property, and the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Gets the underlying <see cref="T:System.Web.HttpPostedFile" /> object for a file that is uploaded by using the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control.</para>
|
||
</summary>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
<Member MemberName="Render">
|
||
<MemberSignature Language="C#" Value="protected override void Render (System.Web.UI.HtmlTextWriter writer);" />
|
||
<MemberType>Method</MemberType>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
<ReturnValue>
|
||
<ReturnType>System.Void</ReturnType>
|
||
</ReturnValue>
|
||
<Parameters>
|
||
<Parameter Name="writer" Type="System.Web.UI.HtmlTextWriter" />
|
||
</Parameters>
|
||
<Docs>
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="M:System.Web.UI.WebControls.FileUpload.Render(System.Web.UI.HtmlTextWriter)" /> method sends the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control content to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to render on the client.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Sends the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control content to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to render on the client.</para>
|
||
</summary>
|
||
<param name="writer">
|
||
<attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control content. </param>
|
||
</Docs>
|
||
</Member>
|
||
<Member MemberName="SaveAs">
|
||
<MemberSignature Language="C#" Value="public void SaveAs (string filename);" />
|
||
<MemberType>Method</MemberType>
|
||
<ReturnValue>
|
||
<ReturnType>System.Void</ReturnType>
|
||
</ReturnValue>
|
||
<Parameters>
|
||
<Parameter Name="filename" Type="System.String" />
|
||
</Parameters>
|
||
<Docs>
|
||
<since version=".NET 2.0" />
|
||
<remarks>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>The <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method saves the contents of an uploaded file to a specified path on the Web server.</para>
|
||
<para>The <see cref="T:System.Web.UI.WebControls.FileUpload" /> control does not automatically save a file to the server after the user selects the file to upload. You must explicitly provide a control or mechanism to allow the user to submit the specified file. For example, you can provide a button that the user clicks to upload the file. The code that you write to save the specified file should call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method, which saves the contents of a file to a specified path on the server. Typically, the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method is called in an event-handling method for an event that raises a post back to the server. For example, if you provide a button to submit a file, the code to save the file to the server could then be included inside the event-handling method for the click event.</para>
|
||
<para>When you call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method, you must specify the full path of the directory on the server in which to save the uploaded file. If you do not explicitly specify a path in your application code, an <see cref="T:System.Web.HttpException" /> exception is thrown when a user attempts to upload a file. This behavior helps keep the files on the server secure, by not allowing users to specify a path in which to save the files that they upload.</para>
|
||
<para>Before calling the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method, you should use the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> property to verify that the <see cref="T:System.Web.UI.WebControls.FileUpload" /> control contains a file to upload. If the <see cref="P:System.Web.UI.WebControls.FileUpload.HasFile" /> returns true, call the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> method. If it returns false, display a message to the user indicating that the control does not contain a file. If you do not provide error-handling code to verify that a file exists, an attempt to save a nonexistent file throws an <see cref="T:System.Web.HttpException" /> exception.</para>
|
||
<para>For a call to the <see cref="M:System.Web.UI.WebControls.FileUpload.SaveAs(System.String)" /> to work, the ASP.NET application must have write access to the directory on the server. There are two ways that the application can get write access. You can explicitly grant write access to the account under which the application is running, in the directory in which the uploaded files will be saved. Alternatively, you can increase the level of trust that is granted to the ASP.NET application. To get write access to the executing directory for the application, the application must be granted the <see cref="T:System.Web.AspNetHostingPermission" /> object with the trust level set to the <see cref="F:System.Web.AspNetHostingPermissionLevel.Medium" /> value. Increasing the level of trust increases the application's access to resources on the server. Note that this is not a secure approach, because a malicious user who gains control of your application will also be able to run under this higher level of trust. It is a best practice to run an ASP.NET application in the context of a user who has the minimum privileges that are required for the application to run. For more information about security in ASP.NET applications, see <format type="text/html"><a href="3eeeee9e-b09f-4c7f-8ce5-d9ca1f9322ad">Basic Security Practices for Web Applications</a></format> and <format type="text/html"><a href="F897C794-10D3-414C-86B7-59B66564BBF1">ASP.NET Trust Levels and Policy Files</a></format>.</para>
|
||
</remarks>
|
||
<summary>
|
||
<attribution license="cc4" from="Microsoft" modified="false" />
|
||
<para>Saves the contents of an uploaded file to a specified path on the Web server.</para>
|
||
</summary>
|
||
<param name="filename">
|
||
<attribution license="cc4" from="Microsoft" modified="false" />A string that specifies the full path of the location of the server on which to save the uploaded file. </param>
|
||
</Docs>
|
||
<AssemblyInfo>
|
||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||
</AssemblyInfo>
|
||
</Member>
|
||
</Members>
|
||
</Type> |