An error occurred while uploading the image in Sitecore Media Library

783 views Asked by At

I want to manually upload an image into specific folder in the Sitecore Media Library.

While uploading the image I am getting an error saying An error occurred while uploading a file. The reason may be the that the file does not exist or the path is wrong.

Please see the screenshot below: enter image description here

I have tried to change some configuration settings in the Sitecore.Speak.Applications.config file but still having the same issue.

Please advise what can be causing this error.

1

There are 1 answers

4
Anna Gevel On

I saw a similar error in the past and in my case it was caused by a duplicate item name in the Media Library folder.

Image names in each media folder should be unique. If you try to upload a file with the name that already exists in the selected folder, Sitecore will return the message saying "the file does not exist or the path is wrong". If this is the problem, you will see the error Sitecore.Exceptions.DuplicateItemNameException in Sitecore log file:

35220 12:30:19 ERROR Could not save posted file: test.png
Exception: Sitecore.Exceptions.DuplicateItemNameException
Message: The item name "test" is already defined on this level.
Source: Sitecore.Kernel
   at Sitecore.Data.Items.ItemUtil.AssertDuplicateItemName(Item destinationItem, Item sourceItem, String name)
   at Sitecore.Data.Items.ItemUtil.AssertItemName(Item destinationItem, Item sourceItem, String name)
   at Sitecore.Data.Items.Item.Add(String name, TemplateID templateID)
   at Sitecore.Resources.Media.MediaCreator.CreateItem(String itemPath, String filePath, MediaCreatorOptions options)
   at Sitecore.Resources.Media.MediaCreator.AttachStreamToMediaItem(Stream stream, String itemPath, String fileName, MediaCreatorOptions options)
   at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, MediaCreatorOptions options)
   at Sitecore.Resources.Media.MediaUploader.UploadToDatabase(List`1 list)
   at Sitecore.Resources.Media.MediaUploader.Upload()
   at Sitecore.Pipelines.Upload.Save.Process(UploadArgs args)

UPDATE:

I double checked when this error message is used, and it can be caused by any exception thrown during media item creation. Some exceptions are thrown during item name validation: for example, if file name is too long (setting MaxItemNameLength), name ends with ., name starts or ends with spaces or tabs, name contains invalid characters (setting InvalidItemNameChars) or name does not match pattern from the setting ItemNameValidation.

So you can try uploading another file or renaming your file to a simple file name containing only letters and see if it helps.