Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > General Discussions > MVC Extensions: Image Browser delete file and directory not working

Answered MVC Extensions: Image Browser delete file and directory not working

Feed from this thread
  • Mr.Y avatar

    Posted on May 30, 2012 (permalink)

    Hi,

    When an image is uploaded that contains a space or spaces in the name it is not possible to delete it. This is also the case for directories that are created.

    I think this is because the space, in the path argument in the controller, is encoded as %20 when send to the controller.

    Is there a workaround for this. Surely I won't be the fist to come across this behaviour.

    Thanks in advance for any feedback.

    Kind regards,
    Yorrick vd Voort

    Reply

  • Answer Daniel Daniel admin's avatar

    Posted on Jun 4, 2012 (permalink)

    Hello Yorrick vd Voort,

    I reproduced the problem you wrote about and we will investigate what exactly is causing this behavior. A workaround for now is to set custom action methods which to either delete the files and folders or decode the path and call the EditorFileBrowserController methods. For example:
    .FileBrowser(t => t
        .DeleteFile("DeleteEncodedFile", "ImageBrowser")
        .DeleteDirectory("DeleteEncodedDirectory", "ImageBrowser")
        .Browse("Browse", "ImageBrowser")
        .Thumbnail("Thumbnail", "ImageBrowser")
        .Upload("Upload", "ImageBrowser")
        .CreateDirectory("CreateDirectory", "ImageBrowser"))
    public ActionResult DeleteEncodedFile(string path)
    {
        var decodedPath = Server.UrlDecode(path);
        return DeleteFile(decodedPath);
    }
     
    public ActionResult DeleteEncodedDirectory(string path)
    {
        var decodedPath = Server.UrlDecode(path);
        return DeleteDirectory(decodedPath);
    }

    Kind regards,
    Daniel
    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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.

    Reply

  • Mr.Y avatar

    Posted on Jun 6, 2012 (permalink)

    Hi,

    Thanks for the reply and the solution. This helped a lot.
    BTW the issue with the space is also there when you try to open a folder with a space in the name.

    I used your suggestion and created a new method and returned the Browse Jsonresult like below:

     

     

     

    public  JsonResult BrowseEncoded(string path)
    {
        var decodedPath = Server.UrlDecode(path);
        return Browse(decodedPath);
    }

    Regards,
    Yorrick

     

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > General Discussions > MVC Extensions: Image Browser delete file and directory not working