I always get "Adding image failed: Invalid path"

Jul 28, 2011 at 8:40 PM

Hi all,

whatever I do to upload any image - I always get "Adding image failed: Invalid path". Any idea what could be the issue?
I am using IE9, if that matters.


Thanks.

Aug 18, 2011 at 5:49 PM

Did this get resolved? I installed the Image Gallery today on my test machine and get the same error everytime I try and upload an image.

 

Coordinator
Aug 18, 2011 at 5:52 PM

Are you using Windows Azure?

Sorry guys for the delay. I'm having a hard time in my last semester at college.

Thanks for the comprehension ;-)

Aug 18, 2011 at 5:59 PM

Nope this is running on a windows 7 PC with Orchard running under Microsoft WebMatrix at present. Understand, Its hard work! Good luck.

Aug 29, 2011 at 10:29 PM

Hi,

I'm having the same problem - running on Win7 64 Bit - also using Orchard under Microsoft WebMatrix

Hope you can help...

Thanks

Coordinator
Aug 30, 2011 at 1:25 PM

I wasn't able to reproduce this error. Could you guys please send me the path where the application is deployed, the name of the image gallery and the name of the image that you're trying to upload?

Thanks!

Aug 30, 2011 at 3:40 PM

Hi,

C:\Users\Ian\Documents\My Web Sites\Orchard CMS\

http://localhost:5525/Admin/ImageGallery/Images?imageGalleryName=test

Thumbnail 100 x 100 - <label class="forcheckbox" for="ImageGallery_KeepAspectRatio">Keep original image aspect ratio</label>

c:\Temp\side.jpg

Thanks again

Sep 3, 2011 at 8:56 AM

I'm encountering the same issue "Adding image failed: Invalid path".

Orchard is installed locally.
URI for adding is http://localhost:50197/Admin/ImageGallery/AddImages
Default settings for everything, gallery is also named test (renaming does not fix it)
Upload from w:\test.jpg

Thanks in advance!

Oct 11, 2011 at 12:54 PM

Same here as well, it's a fresh clean install of orchard and I'm getting the error:

Adding image failed: Invalid path
Coordinator
Oct 11, 2011 at 1:31 PM

Hi,

Could you please try to debug and verify what is the path that the module is trying to access?

Inside the Modules/Mello.ImageGallery folder there is a "normal" csproj that you can open with Visual Studio and debug as usual. You can either add this csproj to the Orchard solution or you can debug on IIS directly attaching the dubugger.

If your trying to attach the debugger and do not see the symbols loaded, i.e. can make the breakpoint work, do this:

  • Open the csproj and compile it to Debug
  • Copy the Mello.ImageGallery.dll and Mello.ImageGallery.pdb from Mello.ImageGallery bin folder to the Orchard bin folder.

Thanks.

Developer
Nov 17, 2011 at 9:32 AM

I had the same error, it was due the AddImage post was being called with ImageGalleryName = null.

The exception occured when the value was use in a path.combine to create the image galley path.
File ImageGalleryService.cs

return _storageProvider.Combine(ImageGalleriesMediaFolder, imageGalleryName);

 

It can be fixed by changing the AddImage get to put the value in the viewmodel.

File Modules\Mello.ImageGallery\Controllers\AdminController.cs

from

return View(new ImageAddViewModel {AllowedFiles = _imageGalleryService.AllowedFileFormats });

to

return View(new ImageAddViewModel {ImageGalleryName = imageGalleryName, AllowedFiles = _imageGalleryService.AllowedFileFormats });

 

Coordinator
Nov 17, 2011 at 9:37 AM

Hi Chris,

Thank you very much for your debugging :-)

Like I said, I wasn't able to reproduce the error, so I needed someone to help me out. I'll apply this patch and release a new beta version so people can see if this fix their issue.

Hopefully, I'll do it this weekend.

Thanks again!

Gabriel

Developer
Nov 17, 2011 at 10:06 AM

no problem Gabriel,

I would be intererested to know how the imageGalleryName was being passed in the code you have. Does the viewmodel pass to the post AddImage have the value set?

Coordinator
Dec 5, 2011 at 7:01 PM

Guys,

This issue should be fixed in version 1.3 available for download. Let me know if you have any issue.

Thanks everybody!

Gabriel Mello

Dec 11, 2011 at 12:59 PM

Hi,

I'm having the same problem - running on Win7 64 Bit.
Adding image failed: Invalid path.

Hope you can help me.

Thank you. 

Developer
Dec 11, 2011 at 9:38 PM

hi muges.

Thanks for posting, could you do a couple of things for us?
Could you please confirm the version of the gallery (from admin\modules\installed) and orchard(from bottom of website) you are running? Could you also please post the stack trace that is displayed?
Are you able to debug the code or is that not something you don't have experience with?

The original issue was that the imageGalleryName was not being passed in. This has been fixed in 1.3. So it could be that the issues was not fixed 100%, you don't have the latest code, or there is another issue.

As an aside we will look at adding some input parameter checking to the next version so that we get back some more meaning full errors.

Dec 19, 2011 at 4:20 PM
Edited Dec 19, 2011 at 4:23 PM

Hi

How Can i resolve the problem of path?? I have this problem only with internet explorer. It's Ok with firefox. I use  version 1.3 of Image gallery.

Thank you

Coordinator
Dec 20, 2011 at 10:26 AM

Hi,

I think the better approach would be to debug the module and verify where the error is occurring so we can help you further.

gabrielchites wrote:

Hi,

Could you please try to debug and verify what is the path that the module is trying to access?

Inside the Modules/Mello.ImageGallery folder there is a "normal" csproj that you can open with Visual Studio and debug as usual. You can either add this csproj to the Orchard solution or you can debug on IIS directly attaching the dubugger.

If your trying to attach the debugger and do not see the symbols loaded, i.e. can make the breakpoint work, do this:

  • Open the csproj and compile it to Debug
  • Copy the Mello.ImageGallery.dll and Mello.ImageGallery.pdb from Mello.ImageGallery bin folder to the Orchard bin folder.

Thanks.

Jan 4, 2012 at 12:23 AM
Edited Jan 4, 2012 at 12:26 AM

Hi all,

I just for the first time used Orchard -and therefore ImageGallery- and got the same error.  Latest version of Orchard and latest version of the Gallery (1.3).

After some debugging, which helped me to become a bit familiar with Orchard btw, I found the culprit and the fix seems oh-so-easy.  I believe it is the right fix but the project owners have of course the final word.    The chain of events that led to the error was being triggered at ImageGalleryService.cs -> AddImage (galleryName, fileName, imageFile) the call below was passing the file name just as it received upon being called.  

_mediaService.UploadMediaFile(GetMediaPath(imageGalleryName), fileName, imageFile, false);

 The physical file name (on the user's hard drive) comes on the POST message from the user's browser; and different browsers of course send the same information in sightly different ways.  IE sends the full path, which down the road leads to the problem. I assume (am willing to bet) that FireFox just sends filename+extension and therefore no error is triggered. I saw this very same behaviour a few years back when writing an upload routine for work.

The fix for me was to simply to get rid of the path information sent from the client (browser) on the POST at ImageGalleryService.cs line 152:

_mediaService.UploadMediaFile(GetMediaPath(imageGalleryName), Path.GetFileName(filename).Trim(), imageFile, false);

Tested and works for me.  I'm not entirely sure if this "cleaning" should be done higher on the call hierarchy but have to get back to working using the system, so where to clean is open for discussion, I guess.

Thanks Gabriel and whoever else who contributed to this module. It is pretty cool.

Coordinator
Jan 4, 2012 at 8:53 AM

Hello Andress.

Thanks for your feedback.

As you can see on this thread, my main problem is that I wasn't able to reproduce this error. Now that you say that the IE behavior is the cause, that explains why I couldn't find the error :-P 

Your contribution is really appreciated, that's what makes open source worth. 

I’m going to analyze the best way to apply this fix and let you guys know when the change is ready.

Thanks again,

Gabriel

Jan 6, 2012 at 7:20 PM

Sure thing!  When I saw the message the first time I knew it had to do with the headers because I have seen this in the past... I'll keep it in mind for the next odd path-related issue.  Cheers to all,

Feb 7, 2012 at 2:24 PM
Edited Feb 7, 2012 at 2:24 PM

I have come across this issue as well, posted the workitem here http://orchardimagegallery.codeplex.com/workitem/19

Put my fix in the AddImage method where it uses the HttpPostedFileBase.FileName, which is where the issue originates.

Apr 6, 2012 at 7:39 AM

This fix sorted out the same problem in a fresh install of Orchard 1.4.  Thanks.

Aug 7, 2012 at 1:52 AM

Hi,

This is still happening in the latest release.. (installed 1 Aug). It only happening on Internet Explorer (9 is the only version i am able to test). The problem doesnt occur in Chrome.

_mediaService.UploadMediaFile(GetMediaPath(imageGalleryName), Path.GetFileName(filename).Trim(), imageFile, false);

I tried the above line of code, but it caused the Module to not compile correctly. Any help would be great!

Thanks

Aug 7, 2012 at 1:39 PM
brentos wrote:

Hi,

This is still happening in the latest release.. (installed 1 Aug). It only happening on Internet Explorer (9 is the only version i am able to test). The problem doesnt occur in Chrome.

_mediaService.UploadMediaFile(GetMediaPath(imageGalleryName), Path.GetFileName(filename).Trim(), imageFile, false);

I tried the above line of code, but it caused the Module to not compile correctly. Any help would be great!

Thanks


Hello back,

This one is of the simplest fixes ever. What is the compiler error, and where does it fail?  Does it compile everything before making the change?  Compiling Orchard for the first time can be quite the task for the uninitiated (in Orchard).

If you undo the change and on Visual Studio issue a "Rebuild All" command, does it work?  Need more info...

Dec 11, 2012 at 7:26 AM

Still happening for me, with orchard 1.6 - a new downloaded version. in all browsers

Jan 30, 2013 at 12:27 AM

Was able to replicate issue when debugging orchard v.1.6 with IE9, (Chrome was fine)

mappedPath = "C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg"

basePath = "C:\Code\vatech\Orchard.Source.1.6\src\Orchard.Web\Media\Default"

ArgumentException("Invalid path");

Orchard.Framework.dll!Orchard.Validation.PathValidation.ValidatePath(string basePath, string mappedPath) Line 32
Orchard.Framework.dll!Orchard.FileSystems.Media.FileSystemStorageProvider.MapStorage(string path) Line 45
Orchard.Framework.dll!Orchard.FileSystems.Media.FileSystemStorageProvider.CreateFile(string path) Line 241
Orchard.Framework.dll!Orchard.FileSystems.Media.FileSystemStorageProvider.SaveStream(string path, System.IO.Stream inputStream) Line 282
Orchard.Media.dll!Orchard.Media.Services.MediaService.UploadMediaFile(string folderPath, string fileName, System.IO.Stream inputStream, bool extractZip) Line221 Mello.ImageGallery.Services.ImageGalleryService.AddImage(string imageGalleryName, string fileName, System.IO.Stream imageFile) Line 152
Mello.ImageGallery.Services.ImageGalleryService.AddImage(string imageGalleryName, System.Web.HttpPostedFileBase imageFile) Line 139 Mello.ImageGallery.Controllers.AdminController.AddImages(Mello.ImageGallery.ViewModels.ImageAddViewModel viewModel) Line 150

 

May 3, 2013 at 10:32 PM
Hi,

facing the same invalid path error in 1.6 with Image Viewer 1.3. Will appreciate help
Jul 23, 2013 at 6:54 PM
Looking at the latest source, this issue still isn't fixed.

Do you need someone to submit a patch on this? I've got one ready. Is this project being maintained?

Bryan

Feb 11 at 6:25 AM
Hi All,

I was facing the same error. But my solution was very simple. My first Image Gallery name was “Content”, because I wanted to store images for my content in that gallery.

I couldn’t upload any image, but then it hit me; there already was a path /Content in use, so that was my issue. So I created a new library (named mine SiteImages) and now it’s ok!

Hope it helps…