This control will present the user with an upload file dialog box

http://www.developerfusion.co.uk/show/3905/2/

Now that we have a warm, fuzzy place to store our images, lets build a webform to upload our images into the database.

Enter A Friendly Name <input type=text id=txtImgName runat="server" >
<asp:RequiredFieldValidator id=RequiredFieldValidator1 runat="server" ErrorMessage="Required" ControlToValidate="txtImgName"></asp:RequiredFieldValidator>
<br>Select File To Upload:
<input id="UploadFile" type=file runat=server>
<asp:button id=UploadBtn Text="Upload Me!" OnClick="UploadBtn_Click" runat="server"></asp:button>
</form>

The first interesting point about our webform, is the attribute "enctype". Enctype tells the browser and server that we will be uploading some type of binary data. This binary data needs to be parsed, using a different mechanism from our normal text data. The next control we of interest is the type=file control. This control will present the user with an upload file dialog box. The user browses for the file they want to upload.

posted on 2005-11-15 00:12  cy163  阅读(217)  评论(0编辑  收藏  举报

导航