Weird problem with upload sometimes not working

4 posts, 0 answers
  1. Matthew Bishop
    Matthew Bishop avatar
    57 posts
    Member since:
    Apr 2007

    Posted 01 Feb 2013 Link to this post

    I have a strange problem!
    When I upload via the windows explorer upload facility on 4 out 60 directories it does not upload the files.

    The directories are all created via Directory.Create();
    The 4 directories that are in question are not the longest file names, but all have similar names, they are:
    Safari Bella Leopard
    Safari Bella Zebra
    Safari Tall Leopard
    Safari Tall Zebra


    yet the file names:
    Safari Short Zebra Collection
    Safari Short Leopard Collection

    work fine and more interestingly I can create the dummy file "blah.txt" (as you can see in the code below) in the directories that are having the issues.

    Below is the code I use
    <telerik:RadFileExplorer ID="RadFileExplorer1" Runat="server"
                                Width="600px" EnableAsyncUpload="True"
            EnableCreateNewFolder="False" ExplorerMode="Thumbnails"
                                VisibleControls="Toolbar, ContextMenus, FileList"
            AvailableFileListControls="Thumbnails" Skin="Office2010Blue">
                                <Configuration EnableAsyncUpload="True" SearchPatterns="*.*" />
                            </telerik:RadFileExplorer>

    string physicalPath = Directory.GetParent(Server.MapPath("").ToString()).ToString() + "\\Product Images\\" + Request.QueryString["id"].ToString();
    if (!Directory.Exists(physicalPath))
    {
    try
    {
    Directory.CreateDirectory(physicalPath);
    }
    catch (Exception ex) { RadAjaxManager1.Alert(Misc.CleanForDatabase(ex.Message)); }
    }
    try
    {
    File.CreateText(physicalPath + "/blah.txt");
    }
    catch (Exception ex1) { RadAjaxManager1.Alert(ex1.Message); }
    string[] relativePath = new string[] { "~/Product Images/" + Request.QueryString["id"].ToString() + "/" };
    RadFileExplorer1.Configuration.UploadPaths = relativePath;
    RadFileExplorer1.Configuration.DeletePaths = relativePath;
    RadFileExplorer1.Configuration.ViewPaths = relativePath;
    RadFileExplorer1.Configuration.MaxUploadFileSize = 10485760;

    I hope someone has some ideas on this... I have exhausted all of mine ((

    Thanks in advance :)
  2. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 06 Feb 2013 Link to this post

    Hi Matthew,

    There are some possible reasons which might cause a similar behavior:

    First of all - could you confirm that you are setting the paths of FileExplorer in the Page_Load event (or earlier)? This is the latest moment of the page life cycle in which you can configure RadFileExplorer, and if you are doing it in a later event, that could cause the issue.

    Another possible thing could be if you do not have enough permissions to create/upload files in some of the folders. For more information on how to test the folders permissions, please, refer the following help article: TrubleShooting.

    The last reason I could think of is if the FileExplorer on your page is updated via AJAX (e.g. if it is wrapped inside the RadAjaxLoadingPanel1 control). Note, that FileExplorer's functionality is heavily based on client-side callbacks and it is highly not recommended to be externally ajaxified. If so - could you please disable the AJAX and see if the problem still exists?

    If non of the above is the case, could you prepare a sample fully runnable project reproducing the issue so we will be able to examine and debug it locally?

    Regards,
    Vesi
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matthew Bishop
    Matthew Bishop avatar
    57 posts
    Member since:
    Apr 2007

    Posted 06 Feb 2013 Link to this post

    Hi Vesi,
    I have added all the code I use below. It is a very simple page that is dedicated to simply uploading files. The permissions are correct as the directories are created by the web application and I can write to many other folders that have been created by the application(there are about 60 different folders). Also is I try write the test file 'blah.txt' then the file can be written.

    I have used the file explorer control for years and have never run into this type of problem, hence my request for some assistance.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductImageManager.aspx.cs" Inherits="BlissBoots.Administration.ProductImageManager" %>
     
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.Core.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.jQuery.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.jQueryInclude.js">
                </asp:ScriptReference>
            </Scripts>
        </telerik:RadScriptManager>
                            <telerik:RadFileExplorer ID="RadFileExplorer1" Runat="server"
                                Width="600px" EnableAsyncUpload="True"
            EnableCreateNewFolder="False" ExplorerMode="Thumbnails"
                                VisibleControls="Toolbar, ContextMenus, FileList"
            AvailableFileListControls="Thumbnails" Skin="Office2010Blue">
                                <Configuration EnableAsyncUpload="True" SearchPatterns="*.*" />
                            </telerik:RadFileExplorer>
        </form>
    </body>
    </html>

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    namespace BlissBoots.Administration
    {
        public partial class ProductImageManager : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    try
                    {
                        string physicalPath = Directory.GetParent(Server.MapPath("").ToString()).ToString() + "\\Product Images\\" + Request.QueryString["id"].ToString();
                        if (!Directory.Exists(physicalPath))
                        {
                            try
                            {
                                Directory.CreateDirectory(physicalPath);
                            }
                            catch (Exception ex) { RadAjaxManager1.Alert(Misc.CleanForDatabase(ex.Message)); }
                        }
                        try
                        {
                            File.CreateText(physicalPath + "/blah.txt");
                        }
                        catch (Exception ex1) { RadAjaxManager1.Alert(ex1.Message); }
                        string[] relativePath = new string[] { "~/Product Images/" + Request.QueryString["id"].ToString() + "/" };
                        RadFileExplorer1.Configuration.UploadPaths = relativePath;
                        RadFileExplorer1.Configuration.DeletePaths = relativePath;
                        RadFileExplorer1.Configuration.ViewPaths = relativePath;
                        RadFileExplorer1.Configuration.MaxUploadFileSize = 10485760;
                    }
                    catch (Exception ex2) { RadAjaxManager1.Alert(Misc.CleanForDatabase(ex2.Message)); }
                }
            }
        }
    }
  5. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 11 Feb 2013 Link to this post

    Hi Matthew,

    Thank you fro the provided code - unfortunately I tried to reproduce the described issue, but to no avail. Please, take a look at the video from my test here and let me know if there is anything, which I may be leaving out.

    The modifications I needed to make in the provided code to make it runnable, are as follows:
     - I have changed the path to the root directory to be "~/" to make sure that the created folder would be placed inside the application's root:
    string physicalPath = Directory.GetParent(Server.MapPath("~/").ToString()).ToString() + "\\Product Images\\" + Request.QueryString["id"].ToString();

     - I have ednabled all of the visible controls, in order to keep an eye on the current root folder (in the TreeView and the path to it in the AddressBar)

    Additionally, since you have set the MaxUploadFileSize = 10485760 (which is bigger than 4MB), could you, please, verify that you have also made the corresponding configurations in the web.config? You can take a look at this help article for reference on what steps to take in order to allow for large files uploads.

    Regards,
    Vesi
    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.
Back to Top