Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am working with Umbraco 8 and I cant upload the Image in media file from the frontend of my website.

Code which I am using working fine in Umbraco 7, but cant get ti work in Umbraco 8.

tHIS IS ecception from Log viewer
System.IO.FileNotFoundException: Could not find file 'C:\Users\josip\source\repos\UmbracoOsam\UmbracoOsam\media\System.Web.HttpPostedFileWrapper'.
File name: 'C:\Users\josip\source\repos\UmbracoOsam\UmbracoOsam\media\System.Web.HttpPostedFileWrapper'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Umbraco.Core.IO.PhysicalFileSystem.OpenFile(String path)
   at Umbraco.Core.IO.ShadowWrapper.OpenFile(String path)
   at Umbraco.Core.IO.FileSystemWrapper.OpenFile(String path)
   at Umbraco.Web.Media.UploadAutoFillProperties.Populate(IContentBase content, IImagingAutoFillUploadField autoFillConfig, String filepath, String culture, String segment)


What I have tried:

Controller:
foreach (var file in model.Files)
            {
                var media = Services.MediaService.CreateMedia(file.FileName, 1051, "Image");
                media.SetValue("umbracoFile", file);
                
                Services.MediaService.Save(media);
                
            }

Model:
[Required]
        public IEnumerable<HttpPostedFileBase> Files { get; set; }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900