Copied to clipboard

Flag this post as spam?

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


  • Mark Watson 118 posts 384 karma points
    Nov 21, 2019 @ 03:23
    Mark Watson
    0

    Downloading a pdf using media picker

    I can not seem to get this to work. I am new to Umbraco using Umbraco Cloud v8 and this code is in a partial.

    I would like to be able to click on the item name and download the pdf. The pdf has been uploaded using the media picker and the item displayed on the page.

    @foreach (var item in selection)
        {
    
    
        var typedMediaPickerSingle = item.Value<IPublishedContent>("coverageLogo");
                  if (typedMediaPickerSingle != null)
                  {
            <p class="literature-container">
                <a href=" @item.Url("coverageDocumentPdf")">@item.Name</a>
            </p>
    
            <p class = "literature-image"><img [email protected] /> </p>
        }
        }
    

    @item.Url("coverageDocumentPdf") gives the path /coverage/pdfcoveragetest/ and @item.Value("coverageDocumentPdf") gives Umbraco.web.pubishedModels.File.

    How do I display the link to download the file /xxxx/xxxx/pdfname.pdf?

  • Marc Goodson 2141 posts 14324 karma points MVP 8x c-trib
    Nov 21, 2019 @ 22:23
    Marc Goodson
    101

    Hi Mark

    would

    var coverageDocumentPdf = item.Value<IPublishedContent>("coverageDocumentPdf");
    
    <a href="@coverageDocumentPdf.Url">@coverageDocumentPdf.Name</a>
    

    yield the Url of the pdf file item?

    It depends on what property editor type the coverageDocumentPdf property is...

    If it's a media picker configured to pick a single item, then by using the above, by using

    regards

    Marc

  • Mark Watson 118 posts 384 karma points
    Nov 22, 2019 @ 02:32
    Mark Watson
    0

    Thanks Marc

    Thought it would be straight forward just could not work it out.

Please Sign in or register to post replies

Write your reply to:

Draft