Upload Images to Folder

  •  07-23-2012, 6:32 AM

    Upload Images to Folder

    When I upload an image file, the upload starts and i see the checkmark next to the file name that shows the upload was completed. However when I go to the folder the that the images should be in; nothing is there. Here is my code:
     <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        void InsertMsg(string msg)
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        void ButtonPostBack_Click(object sender, EventArgs e)
            InsertMsg("You clicked a PostBack Button.");

        void Uploader_FileUploaded(object sender, UploaderEventArgs args)
            InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");
            args.CopyTo("~/images" + args.FileName);
            System.IO.Stream data = args.OpenStream();

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Simple Upload with Progress (Custom Validation) </title>
        <link rel="stylesheet" href="demo.css" type="text/css" />
        <form id="form1" runat="server">
            <div class="content">
                <asp:ScriptManager ID="Scriptmanager1" runat="server">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            Simple Upload with Progress (Custom Validation)
                            A sample demonstrating how to create user-defined validation functions for an upload
                            control. In this example, we defined two validation rules:</p>
                            <li>Maximum file size: 1000K</li>
                            <li>Allowed file types: jpeg, jpg, gif,png </li>
                            Click the following button to upload.
                        <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertText="Upload" OnFileUploaded="Uploader_FileUploaded">
                            <ValidateOption AllowedFileExtensions="jpeg,jpg,gif,png" MaxSizeKB="1000" />
                            Server Trace:
                            <br />
                            <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
                        <asp:Button ID="ButtonPostBack" Text="This is a PostBack button" runat="server" OnClick="ButtonPostBack_Click" />

View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems