Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rob Watkins 369 posts 701 karma points
    Mar 03, 2011 @ 11:37
    Rob Watkins
    0

    Uploading files to umbraco from outside admin

    I am creating a member profile page where they can upload an image to go along with their details - basically an avatar I guess, but can be quite large as is not used exactly like an avatar.

    Is there a control available in any of the Umbraco assemblies I can just drop in that basically does what the ASP.NET file upload does except it saves everything to the media library and gives me the ID back?

    I presume the uploadField datatype must do something like that, but I can't find just a Control I can drop in.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 03, 2011 @ 12:18
    Dirk De Grave
    0

    can't you just go with a standard asp.net upload control and create media item using the media api?

     

    Cheers,

    /Dirk

  • Rob Watkins 369 posts 701 karma points
    Mar 03, 2011 @ 12:22
    Rob Watkins
    0

    That would be a perfectly acceptable substitute if there is no preexisting control, can you point me to some examples / documentation? Or even just the assembly / namespace / class to look at.

    I don't want to wade through the source particularly, if I can do it by looking at the metadata from the assemblies I would prefer that, just need to know where to start looking.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 03, 2011 @ 12:28
    Dirk De Grave
    0

    Here's a link to using the document api, which is quite similar to the media api (can't find any docs on media api atm)... references in the using section should get you to the Media class as well

    http://our.umbraco.org/wiki/reference/api-cheatsheet/creating-a-document

    Cheers,

    /Dirk

  • Rob Watkins 369 posts 701 karma points
    Mar 03, 2011 @ 12:51
    Rob Watkins
    0

    Aha, found this other thread - that you answered, in fact! :o)

    http://our.umbraco.org/forum/developers/api-questions/7962-Update-media

    For anyone else finding this thread, the assembly is "cms.dll", and the namespace is "umbraco.cms.businesslogic.media"

  • Rob Watkins 369 posts 701 karma points
    Mar 03, 2011 @ 13:58
    Rob Watkins
    0

    Found a thread that covers exactly what I want to do, no idea why it was no returned on my original Google!

    http://our.umbraco.org/forum/developers/api-questions/16310-Create-new-media-using-API

    Thanks for your help, Dirk.

  • Rob Watkins 369 posts 701 karma points
    Mar 03, 2011 @ 17:34
    Rob Watkins
    0

    One final question however - it's all working perfectly now, uploading the image, I am settign width / height, everythign groovy - however, it doesn't in the Contents of the parent folder - should it? If so, how does one go about that?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 03, 2011 @ 21:08
    Dirk De Grave
    0

    Hmm, not sure what you mean? seems some words have fallen off?

     

    /Dirk

  • Rob Watkins 369 posts 701 karma points
    Mar 04, 2011 @ 10:21
    Rob Watkins
    0

    Wow, you're right, that makes no sense whatsoever, looks like I was having some kind of seizure :o) Let's try again.

    In the Media section, when you click on a folder, you get the Contents tab, containing a Contents control with thumbnails of all the images in the folder. I assumed that was generated automatically by whatever was in the folder, but when I upload stuff using the API, although it is all in the library fine and can be used, it does not appear in the Contents control of the parent folder.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 04, 2011 @ 10:26
    Dirk De Grave
    1

    Rob,

    Guess that's because you're using the Media api, which may not create the thumbnails... Probably the only solution to have those thumbnails (if you must), is to create those yourself... shouldn't be too difficult (you can use the umbraco source for the upload editor control)

     

    Cheers,

    /Dirk

  • Rob Watkins 369 posts 701 karma points
    Mar 04, 2011 @ 10:32
    Rob Watkins
    0

    Aha! So it uses pre-created thumbnails rather than just thumbnailing on the fly. I don't particularly care about that right now so I think I'll leave it. Thanks for you help!

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 04, 2011 @ 10:33
    Dirk De Grave
    0

    Yup, as soon as you upload through the media section, thumbnails are created based on configuration in umbracoSettings.config.

     

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft