Devin Gleason Lambert
Devin Gleason Lambert

Reputation: 1730

Uploading Images to Umbraco UploadField Programmatically

So I have a dilemma. I have all these UploadFields attached to content nodes, and when I add an image using the Umbraco 7 CMS dashboard, it creates a space for it at a /media/{id}/{image_name.extension}.

I see no way to do this via C# in the same way it is done via the dashboard. Everything I have tried using the MediaService actually puts it in the media tab and none of the other images reside there so something is different.

I got around this for awhile by just managing where it lived on my own by just making another directory in media for this stuff but now I have integrated a blob storage and my files wont go to the blob storage unless it is using the proper Umbraco default handlers.

Thanks Again, Devin

Upvotes: 1

Views: 812

Answers (1)

wingyip
wingyip

Reputation: 3536

i would not put an uploadfield on a content item. You create media items in the media section and then point to them from content with pickers.

If you put a media picker or a multi-node-tree-picker on a content item, they will give the facility to pick and upload media at the same time. This I think would be the solution to your issue. Creating media programmatically will fit in with this way of doing things.

It may involve a little rework but often trying to get umbraco to do things that are non standard will lead to a great deal more work.

Upvotes: 2

Related Questions