Copied to clipboard

Flag this post as spam?

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


  • George 4 posts 83 karma points
    Aug 23, 2017 @ 11:57
    George
    0

    Get ID of single uploaded file

    Hi, In my View, Im trying to get the ID of the file that is uploaded with Umbraco.UploadField.

    I can easily get the url of the file with code :

    var TFile = CurrentPage.SingleTenderFile;
    

    But i really can't find a way to get the ID of file.

    I also tried :

    @if (CurrentPage.SingleTenderFile != null && !(CurrentPage.SingleTenderFile is Umbraco.Core.Dynamics.DynamicNull))
                            {
                                var m = Umbraco.Media(CurrentPage.SingleTenderFile);
    
                                @m.Id
                            }
    

    But gives m.Id = 0 Is there any other code I can use to get the id? Im using 7.4

    Regards George

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Aug 28, 2017 @ 14:42
    Alex Skrypnyk
    100

    Hi George

    You can't get Id if you are using Umbraco.UploadField. Try to use Media Picker or ImageCropper, then you will have media item for each uploaded file and Id.

    Thanks,

    Alex

  • George 4 posts 83 karma points
    Aug 29, 2017 @ 05:11
    George
    0

    Hi Alex, thank you for the reply. I will replace uploadfield with media picker.

    Regards George

Please Sign in or register to post replies

Write your reply to:

Draft