Cannot use CopyTo() on IIS 7 (windows vista)

Last post 01-10-2012, 7:21 AM by Kenneth. 6 replies.
Sort Posts: Previous Next
  •  01-09-2012, 2:47 AM 72551

    Cannot use CopyTo() on IIS 7 (windows vista)

    I can use the CopyTo() to copy the uploaded file to specified folder under VS2008 (debug mode), when I publish the web site to IIS 7, the file can save into the temp folder but cannot copy to specified folder.
     
    Can you help me ?
     
    Lonnie 
  •  01-09-2012, 5:32 AM 72555 in reply to 72551

    Re: Cannot use CopyTo() on IIS 7 (windows vista)

    Hi Lonniekong,
     
    Did you get any error?
     
    Is your site online? If so, can you send me the uploader page url?
     
    Ensure that your site has the write/read permission of the store folder.
     
    Can you show me your code? 
     
    Regards,
     
    Ken 
  •  01-09-2012, 8:30 AM 72562 in reply to 72555

    Re: Cannot use CopyTo() on IIS 7 (windows vista)

    Dear Ken, ASPX web.config --> the web site in my PC (intranet), so cannot provide the link to you to test it, sorry ? Lonnie
  •  01-09-2012, 8:37 AM 72563 in reply to 72555

    Re: Cannot use CopyTo() on IIS 7 (windows vista)

    Dear Ken, ASPX web.config --> the web site in my PC (intranet), so cannot provide the link to you to test it, sorry ? Lonnie
  •  01-09-2012, 8:39 AM 72564 in reply to 72563

    Re: Cannot use CopyTo() on IIS 7 (windows vista)

    It is ASPX 
     
    <script runat="server">
        void InsertMsg(string msg)
        {
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        }
        void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
            Uploader uploader = (Uploader)sender;
            InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");
                       
            //Copys the uploaded file to a new location.
            String str_saveas = Server.MapPath("~/UploadFile/");
            args.CopyTo(str_saveas + args.FileName);              
            //You can also open the uploaded file's data stream.
            //System.IO.Stream data = args.OpenStream();
        }
    </script>
  •  01-09-2012, 8:39 AM 72565 in reply to 72564

    Re: Cannot use CopyTo() on IIS 7 (windows vista)

    It is web.config
     
    <?xml version="1.0"?>
    <configuration>
      <appSettings>
        <!-- You can set a low upload speed to test the progress bar. -->
        <!-- 
    <add key="CuteWebUI.AjaxUploader.UploadSpeedKB" value="20" />
    -->
        <add key="CuteWebUI.AjaxUploader.TempDirectory" value="~/UploaderTemp"/>
      </appSettings>
      <system.web>
        <httpRuntime maxRequestLength="2000000"/>
        <pages>
          <controls>
            <add namespace="CuteWebUI" assembly="CuteWebUI.AjaxUploader" tagPrefix="CuteWebUI"/>
          </controls>
          <namespaces>
            <add namespace="System.Collections.Generic"/>
            <add namespace="System.IO"/>
            <add namespace="System.Data"/>
            <add namespace="System.Data.SqlClient"/>
          </namespaces>
        </pages>
        <compilation debug="true"/>
        <httpModules>
          <add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
        </httpModules>
      </system.web>
    </configuration>
  •  01-10-2012, 7:21 AM 72587 in reply to 72565

    Re: Cannot use CopyTo() on IIS 7 (windows vista)

    Hi Lonniekong,
     
    Please try the example below, it will save the upload file to the root of your site. Does it work for you?
     
    <%@ Page Language="C#" Title="Customize the queue UI" %>
    <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <script runat="server">
        protected void UploadAttachments1_FileUploaded(object sender, UploaderEventArgs args)
        {
            args.CopyTo("~/"+args.FileName);
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
        <form id="Form1" runat="server">
            <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnFileUploaded="UploadAttachments1_FileUploaded">
            </CuteWebUI:UploadAttachments>
        </form>
    </body>
    </html>
     
    Regards,
     
    Ken 
View as RSS news feed in XML