This is a migrated thread and some comments may be shown as answers.

[Solved] Image/directory doesn't delete when having spaces (&nbsp) in it's name

1 Answer 73 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel
Top achievements
Rank 1
Daniel asked on 21 Mar 2012, 02:40 PM
Hello ! 

   I have a problem with the MVC -> Editor -> Image Browser : when I upload an image with name like "Image Name.png", then I can't delete it. (It looks like it deletes the image, but, in reality,  the image is still there).
  When I upload the image with a name like "Image_Name" (without any spaces) , it works perfect.

  The same when I create a new directory.

 Is there a solution to work this out ?

  Thanks ,
      Daniel

1 Answer, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 22 Mar 2012, 11:31 AM
Never mind !
  
   I did it by overriding my Upload method like this :

 public override ActionResult Upload(string path, HttpPostedFileBase file)
        {
            var newFileName =  file.FileName.Replace(' ''_');
            file.SaveAs(Server.MapPath(path) + newFileName);
 
            return Json(new {Name = newFileName, Size = file.ContentLength.ToString()});
        }

Here, I replace every space with "_",and so an image name like "Image Name" will became "Image_Name".

 But there's still the "New Folder problem", because CreateDirectory(string path,string name) 
it's not virtual, and so it can't be override. 
 Maybe you should consider this in a future release.   


  Best wishes,
    Daniel B.
Tags
Editor
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Share this question
or