Getting Started with C1Upload

Posted by: inactive_user on 10 September 2017, 11:27 am EST

  • Posted 10 September 2017, 11:27 am EST

    I am trying to use the new C1Upload control I have placed it on the page as follows:



    I set ShowProgress to False because I get a message: "Can't get the upload progress" when I click the Upload button.


    With it set to false, things seem to execute, but I cannot find the file anywhere. Do I have the path info correct? There is no sample for the C1Upload control that I can find anywhere. The ComponentOne Studio for ASP.NET Help does not show any examples either.

    Also, I get the message: "Error 8 Cannot create an object of type 'System.String[]' from its string representation '.pdf' for the 'ValidFileExtensions' property" when I try to set ValidFileExtensions=".pdf".

    Thanks,


    Corey

  • Replied 10 September 2017, 11:27 am EST

    OK... I added these lines to web.config:








    The file is copied to the temp folder now, but not to the target folder. I get a message "Too many files". MaximumFiles is set to 1, though.


     Thanks...

  • Replied 10 September 2017, 11:27 am EST

    Thanks for the help. I added that line to web.config. Now everything seems to execute properly, I just don't see the file in the physical target folder. (The folder does exist) What will be the format for the path for the TargetFolder?


    Also... What is the string format for the ValidFileExtensions parameter? I tried ".pdf" and it gives me the error I mentioned earlier.


     Thanks,


     Corey

  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


    Which build are you using? I just tested build 134 and I don't get the errors you are getting. I attached the newer build, 134, which includes bits for the 2.0 framework, if you need it for 3.5 please let me know and I will post the ones for the 3.5 framework.


    When the C1Upload control first uploads the files it places it in the Temp folder and then places it in the Target folder once the file requirements are met. You need to create a Target folder and a Temp folder on your drive. Once you have an existing Target folder and Temp folder you need to set the TargetPhysicalFolder and TempFolder property to the path where your Target and Temp folders are located. For example lets say you have a Target folder and a Temp folder located on your C drive in the following folders:


    C:UploadFolderTemp
    C:UploadFolderTarget


    You need to assign the value of the TargetPhysicalFolder property to TargetPhysicalFolder="C:UploadFolderTarget". You also need to assign the value of the TempFolder property to TempFolder="C:UploadFolderTemp".


     The built-in progress should appear after the files have been added and you click on the upload file button.


     Please let me know if this helps.


    Thanks,


     


    2009/08/221015_build134.zip
  • Replied 10 September 2017, 11:27 am EST

    By the way, this is what my control definition looks like now:


    TargetPhysicalFolder="C:TestUpload" TempFolder="C:temp"

    AutoReset="True" MaximumFiles="10" OverwriteExistingFiles="True" MaximumFileSize="0" />

  • Replied 10 September 2017, 11:27 am EST

    I changed MaximumFiles to 10... (MaximumFileSize is set to 0)


    Now I get this:


    Server Error in '/' Application.


    Maximum request length exceeded. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Maximum request length exceeded.

    Source Error:





    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:





    [HttpException (0x80004005): Maximum request length exceeded.]
    System.Web.HttpRequest.GetEntireRawContent() +8768242
    System.Web.HttpRequest.GetMultipartContent() +62
    System.Web.HttpRequest.FillInFormCollection() +168
    System.Web.HttpRequest.get_Form() +68
    System.Web.HttpRequest.get_HasForm() +8723223
    System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
    System.Web.UI.Page.DeterminePostBackMode() +63
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133




    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.4028

  • Replied 10 September 2017, 11:27 am EST

    Hi Cory,


     Sorry I didn't see your earlier questions. I think your file size is too large. If your file size that you are uploading is greater than 4MB y ou need to set the MaxRequestLength in your Web.config file. If you look in the Upload for ASP.NET help and navigate to the "Enabling Large File Size Uploads" topic you will see that you need to set the MaxRequestLength to the following:


    [IIS prior to version 7]



    ...



     


      ...



      


     


    [IIS 7]



    ......
       
         
           
         

       


    This will enable you to upload files up to 100MB.


    Please let me know if this helps.


    Thanks,


     


    Kristy

  • Replied 10 September 2017, 11:27 am EST

    I am using the new v2 controls which are the .3 versions, not the .2 versions. Build 132.


    C1.Web.UI.3.dll 


    C1.Web.UI.Controls.3.dll


    C1.Web.UI.Controls.3.xml

  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


     I attached the new bits for the 3.5 framework.


    In this case you need to add a reference to the C1.Web.UI.Design.3.dll.


    Please let me know if this works for you.


    2009/08/221024_build134Version3.zip
  • Replied 10 September 2017, 11:27 am EST

    Corey:


    I can't reproduce the issues you are getting with the MaximumFiles and the Client-Side events. I clicked the client-side events in the Properties window and I don't get an error when I add the new client side handler. I tested both issues using build 134. Could you please zip up your project and send it over to me so i can look at it?


    You have the correct format for the TargetFolder property. It uses a relative path. The ~ represents the web application’s physical path. That is, if the web site is rooted at the physical path C:WebSitesUpload, ~/Drawing would be equivalent to C:WebSitesUploadDrawing. The uploaded file is placed in the Drawing folder.


    Note: If you have the paths set for both the TargetFolder and the TargetPhysicalFolder properties, the file will be uploaded to the TargetPhysicalFolder since it takes precedence over the TargetFolder. If you only want it to go the virtual path remove the value from the TargetPhysicalFolder property.


    I just sent your questions over to the developer so he can help you with some of your questions that I could not answer. You should hear back from us shortly.


    Thanks,


     Kristy

  • Replied 10 September 2017, 11:27 am EST

    Kristy,


    OK... I got all of my References and my Toolbox issues worked out and tested the control. It works how you said. But... It still throws an exception if I leave MaximumFiles = 1. I have to set it to at least 2 to get it to execute.


    Also... What will the path look like for the TargetFolder? Will it be a relative path like "~/drawings/"?


    I am also going to want to change the name of the file before uploading. Is this possible? I want to change the name to match the ID of a record.


    One other thing. :D


    When I click on a Client-Side Event in the Properties window and select "Add new client side handler" I get the error: "error hresult e_fail has been returned from a call to a com component".


    Thanks,


    Corey


    I added this code to my app to handle the renaming of the file:


        Protected Sub C1UploadDXF_Uploaded(ByVal sender As Object, ByVal e As EventArgs)
            Dim ctl As Label = Me.fvDetail.FindControl("lblPartNumber")
            Dim Upload As C1.Web.UI.Controls.C1Upload.C1Upload = sender
            Dim MyUploadedFile As String = Upload.UploadedFiles.Item(0).FileName
            Dim MyUploadedFileExtension As String = Upload.UploadedFiles.Item(0).Extension
            Dim Folder As String = Upload.TargetPhysicalFolder.ToString
            IO.File.Copy(Folder & MyUploadedFile, Folder & ctl.Text & "." & MyUploadedFileExtension, True)
            IO.File.Delete(Folder & MyUploadedFile)
        End Sub


    This got the desired result... I just need to know how it will execute in the Virtual folder defined by TargetFolder.

  • Replied 10 September 2017, 11:27 am EST

    I just noticed that when I set the ValidateFileExtensions to any string value C1Upload doesn't add the file to the Target folder. For example if I specify .png for the ValidFileExtensions property and then add a .png file it adds it to the temp folder, but not the target folder. Thank you for bringing this to our attention, Corey. I have reported this behavior to the appropriate individuals. Please check back periodically as I will notify you when this has been corrected.


    For now, If you remove the value from the validatefileextensions property, build your project, and upload a file you will notice the file will go into the Target folder.


    Thanks,


    Kristy

  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


    If you use "pdf" instead of ".pdf" for the ValidFileExtensions property it will place the file in the physical target folder. The developer is modifying the code for C1Upload to accept extensions as pdf, .pdf and *.pdf.


    Regards,


    Kristy

  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


     Did you use the bits I sent you?  I have mine set like the following and it works:


    ValidFileExtensions=".pdf"


     Did you add a reference to the C1.Web.Design.2.dll? The ValidFileExtensions property depends on a converter which exists in the designer dll?


     If it still doesn't work for you please zip up your project and send it to me so I can look at it.


    Thanks,


     Kristy

  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


    Yes we do an NDA if we need to look at the entire application, but to make things easier you can just send over the one page first to see if that's enough to find the problem.


    Regards,


     Kristy

  • Replied 10 September 2017, 11:27 am EST

     I am getting this error: Non-negative number required. Was there a solution for this issue?
  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


    I have an answer for you regarding the file renaming. You can save the uploaded file to any folder and any name, but you need to implement it in the ValidatingFile event like in the sample code below:


    protected void C1Upload1_ValidatingFile(object sender, C1.Web.UI.Controls.C1Upload.ValidateFileEventArgs e)


    {


         // The path parameter in the SaveAs method could be generated by user’s real logic.


            e.UploadedFile.SaveAs(@"c:UploadFolderMyFoldermyfile.png", true);


    }


     


    Regards,


    Kristy

  • Replied 10 September 2017, 11:27 am EST

    Jason,


    It seems to be files of a particular size. I can manipulate the files and change the size slightly and they will upload fine. Unfortunately, I have not taken any notes as to what the file size tends to be. I will try to get a file that causes the problem. How will I email it to you?


    Corey

  • Replied 10 September 2017, 11:27 am EST

    Hi Cardenas,


    Does it happen to all files or particualr file?


    Does it happen when uploading multiple files or single file?


    If it happens on particular file or file with particular size, would you please send me a sample file by email?


    Thanks a lot in advance.

  • Replied 10 September 2017, 11:27 am EST

    Kristy,


    Thanks for the help. I got everything working great.


    But...


    All of a sudden, and I don't know what changed, Internet Explorer is giving this message when I click the "Upload" button:


    "Non-negative number required. Parameter name: count"


    Any ideas?


    Do you folks work with Non-Disclosure agreements? I could not send the whole project. Would just the one page do?


    Corey

  • Replied 10 September 2017, 11:27 am EST

    Hi Corey,


    I believe this problem was fixed recently.  Please try downloading the latest version from:



    http://prerelease.componentone.com/DotNet20/C1WebUI/2010-T1/C1WebUI.2_2.0.20101.174.zip

    If this does not solve the problem, please send a small sample that reproduces the issue, using version .174.  Thanks and I hope this helps.


     


    -Raleigh

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels