ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

display filename of uploaded file only (no path)

March 05, 2012 4:42pm

Subscribe [4]
  • #1 / Mar 05, 2012 4:42pm

    pirco

    218 posts

    I’ve got a file upload folder set-up and when I place the appropriate shortcode in my template it displays the full path (http://www.something.com/images/uploads/customfolder/filename.pdf)

    what’s the easiest way to have it spit out the filename.pdf ONLY ?

    (I’m about to do some PHP string editing but thought I’d ask first)

    thanks

  • #2 / Mar 05, 2012 5:24pm

    Matt:P

    277 posts

    Hi Pirco

    I’ve used File Oracle for this before: http://devot-ee.com/add-ons/file-oracle

    Hope it helps, let us know how you get on…

    Matt

  • #3 / Mar 06, 2012 6:39pm

    Sean C. Smith

    3818 posts

    Hi Pirco,

    You can do this natively with ExpressionEngine when using a field type of “file”. In your code you would use the tag pair option.

    {your_field_name}
    file: {file_name}
    {/your_field_name}

    does this help? Is there anything else I can assist you with?

    Sean

  • #4 / Mar 06, 2012 6:42pm

    Matt:P

    277 posts

    Hey Sean

    Thanks for that! I learned something new today 😊

  • #5 / Mar 08, 2012 4:31pm

    Shane Eckert

    7174 posts

    Hey pirco,

    Does Sean’s solution sound good?

    Let us know what you think and how things are going for you.

    Cheers,

  • #6 / Mar 11, 2012 10:16pm

    spcejunk

    27 posts

    Hey guys,

    I’m trying to use a file field variable pair in similar fashion to get some file info into a podcast feed and having no luck…

    (condensed template code below…)

    <?xml version="1.0" encoding="UTF-8"?>
    {exp:channel:entries channel="podcasts" limit="1"}
    <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
     <channel>
      <title>{title}</title> 
      {reverse_related_entries orderby="date"}  
      <item>
               {audio_file}{file_name}<enclosure url="{url}" length="{file_size}" type="{mime_type}" >{/audio_file} 
      </item>  
      {/reverse_related_entries} 
      </channel>
    {/exp:channel:entries}
    </rss>

    At work is a channel for podcasts and a channel for episodes that are related back to the podcast.

    The audio_file pair returns the following:

    <enclosure url="" length="{file_size}" type="{mime_type}" >

    Everything else inside the reverse related entries works as expected.

    The site is on 2.3.1, but I didn’t notice anything in the change log that would suggest this was a bug that was fixed in 2.4.

    Thoughts?

  • #7 / Mar 12, 2012 5:03pm

    Shane Eckert

    7174 posts

    Hey spcejunk,

    I am sorry to hear you are running into this problem.

    Are you using an Add-On to work with your RSS feed?

    Please let me know and we will go from there.

    Cheers,

  • #8 / Mar 12, 2012 5:58pm

    spcejunk

    27 posts

    No add-ons.

  • #9 / Mar 13, 2012 4:40pm

    Shane Eckert

    7174 posts

    Hi spcejunk,

    What if you take those three tags out of the enclosure. Do they get populated with the values? Just to test and see where this is breaking down.

    Like:

    <?xml version="1.0" encoding="UTF-8"?>
    {exp:channel:entries channel="podcasts" limit="1"}
    <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
     <channel>
      <title>{title}</title> 
      {reverse_related_entries orderby="date"}  
    
        {file_size}  {mime_type}  {url}   
    
      {/reverse_related_entries} 
      </channel>
    {/exp:channel:entries}
    </rss>

    Let me know what that returns.

    Thanks,

  • #10 / Mar 13, 2012 5:55pm

    spcejunk

    27 posts

    You would still need the file field open and close tags though, right?

    Here’s a test I did to eliminate the reverse related entries as the source of the problem…

    {exp:channel:entries channel="podcast_episodes" limit="1"}
    {audio_file}
    URL: {url}
    File size: {file_size}
    Mime type: {mime_type}
    {/audio_file}
    {/exp:channel:entries}

    You can view the results of that here: http://www.stgeorgesepiscopal.net/podcast/test

  • #11 / Mar 15, 2012 2:09pm

    Dan Decker

    7338 posts

    Hi spcejunk,

    I’m sorry to say, the issue here is those tags are only available in ExpressionEngine 2.4

    If you want to take advantage of that native functionality, you’ll have to update.

    Is there anything else we can assist you with?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases