RadUpload does not upload file

Thread is closed for posting
15 posts, 0 answers
  1. David House
    David House avatar
    9 posts
    Member since:
    Mar 2010

    Posted 01 Jun 2010 Link to this post

    We have placed a RadUpload control in a DotNetNuke module and selected the file. We also have an asp:button on the control set to Submit. When we press the button, the RadUpload.UploadedFiles.Count is always ZERO and the file never gets uploaded. The page is being refreshed by the submit button during the postback.

    Here is the GUI code:

     

    <asp:Panel ID="pnlFileUpload" runat="server">

     

    Allowed File Extensions are: .jpg, .gif, .bmp, .png

     

    <telerik:RadUpload id="RadUpload1" Runat="server" AllowedFileExtensions="jpg, gif, bmp, png" TargetFolder="~\Portals\0\ClientLogos" MaxFileInputsCount="1" >

     

     

    </telerik:RadUpload>

     

     

    <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />

     

     

    </asp:Panel>

     



    the btnUpload button is set to UseSubmitBehavior=True. What are we missing?  DotNetNuke version 5.04.02 community.
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 03 Jun 2010 Link to this post

    Hello David House,

    Please make sure that RadUpload is not inside UpdatePanel/RadAjaxPanel or ajafixied using RadAjaxManager. RadUpload cannot upload files using AJAX calls. This is a limitation of the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application. In order to upload a file your application must perform a full page postback. More information on the topic can be found here. You can also take a look at this troubleshoot article, describing a case when the uploaded files collection is empty.

    In addition, information on how RadUpload can be used inside DNN can be found here.

    Best wishes,
    Genady Sergeev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 12 Mar 2012 Link to this post

    I have the exact issue; however, mine is not inside of DNN.
    Here's my code. It's not uploading.

    <telerik:RadUpload ID="RadUpload1" Runat="server" Height="131px"
            MaxFileSize="204800" TargetFolder="~/TempFiles/" TargetPhysicalFolder="~/Upload/">
        </telerik:RadUpload>
        <asp:Button ID="btnUpload" runat="server" Text="Upload" />
  5. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 12 Mar 2012 Link to this post

    Okay, I just followed this Getting Started tutorial and it's still not uploading. Below is my code:
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
    <telerik:RadUpload ID="rduFile" Runat="server" MaxFileSize="204800"
        TargetFolder="~/Media" AllowedFileExtensions=".mp3"
            ControlObjectsVisibility="RemoveButtons"
            MaxFileInputsCount="1" Skin="Forest" Height="25px">
    </telerik:RadUpload>
    <telerik:RadProgressManager ID="RadProgressManager1" Runat="server" />
        <telerik:RadProgressArea ID="RadProgressArea1" Runat="server"
            DisplayCancelButton="True"
            ProgressIndicators="TotalProgressBar, TotalProgress, TotalProgressPercent, RequestSize, FilesCountBar, FilesCount, SelectedFilesCount, CurrentFileName, TimeElapsed, TimeEstimated, TransferSpeed"
            Skin="Forest">
        </telerik:RadProgressArea>
    <asp:Button ID="btUpload" runat="server" Text="Upload" onclick="btUpload_Click" />

    And here's the button click method.
    protected void btUpload_Click(object sender, EventArgs e)
       {
           if (rduFile.UploadedFiles.Count > 0)
           {
               System.Threading.Thread.Sleep(3000);
           }
       }

    Any other suggestion?
  6. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 15 Mar 2012 Link to this post

    Hello Chuck,

    If the UploadedFiles collection is empty than the uploaded file is not valid. The problem in your case is the size of the MaxFileSize property. Please note that this property defines the maximum allow file size in bytes which means that currently you could upload files which are less than 200 killobytes. You should increase this property especially of you want to upload mp3 files. Here you could find a useful only converter.

    Kind regards,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 16 Mar 2012 Link to this post

    Okay, that works. I thought the MaxFileSize property is set KiloByte and not Byte. Anyway, the progress bar never showed up. Any suggestion why?
  8. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 16 Mar 2012 Link to this post

    One other thing, how do I grab the file name of the RadUpload control and store it in my own database?
  9. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 20 Mar 2012 Link to this post

    Hello,

    Here is a sample code showing how to get the name of the uploaded file:
    protected void Button_Click(object sender, EventArgs e)
    {
        foreach (UploadedFile file in RadUpload1.UploadedFiles)
        {
            file.SaveAs(Server.MapPath("~/Uploads/" + file.GetName()));
        }
    }

    You could also use the GetExtension() method which will give you only the extension of the uploaded file.

    Greetings,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  10. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 21 Mar 2012 Link to this post

    Thanks for the response; however, I still not quite get what you're code is trying to do. I'm not trying to save because the RadUpload is already doing that. I'm simply getting the file name. Here is what I've done with the standard FileUpload control in Visual Studio 2010:
    e.Values["fileName"] = FileUpload1.FileName;

    So, the question is. How do I do the same thing with RadUpload? I do not see the "FileName" or "File.GetName" being available.
  11. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 21 Mar 2012 Link to this post

    One other thing is, how do I test if the RadUpload1 uploaded successfully? For example:
    if(RadUpload1.Upload.Success)
    {
    // add the file name into the database here
    }
    else{ e.cancle = true}


  12. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 23 Mar 2012 Link to this post

    Chuck:

    You can refer to the RadUpload Context documentation page which states: "You can access all uploaded files within the current request using the RadUploadContext object. The RadUploadContext object has a single property: UploadedFiles. UploadedFiles is a collection of all files that have been uploaded within the current request."

    UploadedFiles is a collection of all valid uploaded files.

    This is how you can access the name for each uploaded file for that request, using the "GetName()" property:
    foreach (UploadedFile f in RadUpload1.UploadedFiles)
    {  
        // Get the file name for each file that is uploaded
        string fileName = f.GetName();
        // add logic to store this name in your database
    }

    Hope this helps!
  13. Chuck
    Chuck avatar
    14 posts
    Member since:
    Dec 2007

    Posted 26 Mar 2012 Link to this post

    Thanks! I'll give that a try. However, what about my second question? How do I test if the RadUpload1 uploaded successfully?
  14. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 29 Mar 2012 Link to this post

    Hi,

    In case the UploadedFiles collection of the RadUpload is not empty after you have selected a file for upload, than the file is being uploaded successfully.

    All the best,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  15. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 15 Nov 2012 Link to this post

    I am very worry about this issue?
    Path is 100% correct and has full permission. Its work locally as well as on server. but one of our client get this error. i have no idea.
    Can you help me in this? Please see latest images.

    Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Testing\Test.pdf'.

    [DirectoryNotFoundException: Could not find a part of the path 'D:\Testing\Test.pdf'.]
       System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +216
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +2481
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +229
  16. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 24 Nov 2012 Link to this post

    Hi Telerik team and members , please don't use againfile.GetName() or file.FileName.

    I got the solution of this issue, its only arise in IE on few particular computer. After uploading it again and again and checking on client computer. i figure out this. So nobody suffer with again file.GetName() or file.FileName.

    This problem is arise due to this: When we getting UploadedFile  name [  file.FileName.ToString() ]
    So need to use this
    file.GetNameWithoutExtension() + file.GetExtension();
    instead of file.FileName.ToString();

    string targetFolder = System.Web.HttpContext.Current.Server.MapPath(@"~/TestUpload");
    string file1 = file.GetNameWithoutExtension() + file.GetExtension();
    string targetFileName = System.IO.Path.Combine(targetFolder, file1);

    Thanks,
    Muhammad Waseem

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017