I have a link to an uploaded PDF in my template but some of links seem to output a mystery {filedir_3} instead of the path to the upload folder.

So the following template code...

{if download_details}<a href="{download_details}" target="_blank">Download details &raquo;</a>{/if}

outputs as...

<a href="{filedir_3}blahblah.pdf" target="_blank">Download details »</a>

This seems to be occurring on new files and older uploaded files don't seem to be effected. I had a look at the database and the exp_files table doesn't show any obvious different between working and broken links. I upgraded to EE 2.4.0 recently, could this be the issue? I'm not using MSM and the files aren't being uploaded through RTE or wygwam, just through a file channel field.

  • A couple of things: - visit your File Upload Preferences and make sure that the paths and URLs are correct. - from the same screen (File Upload Preferences), synchronize your directories. Commented Feb 7, 2013 at 16:05
  • Thanks for the suggestion but still no luck, the URLs are correct and I tried synchronizing but {filedir_3} is still coming up.
    – Patrick64
    Commented Feb 7, 2013 at 16:26
  • And what does that field look like in the exp_channel_data table? Commented Feb 7, 2013 at 17:22
  • First up, what type of field is download_details? Secondly the code shown above, is it within a Channel Entries Tag or is it totally stand-alone as shown above? If we could see a bit more of your code then I think that might help on this one. Best wishes, Mark
    – Mark Bowen
    Commented Feb 7, 2013 at 18:21
  • Mark, welcome aboard! Can you move your follow-up questions into comments on the original post rather than present them as an answer? Thanks! Commented Feb 7, 2013 at 18:48

2 Answers 2


Just wanted to mention that parse file paths by Rob Sanchez will parse {filedir_X} variables. Usage below:


To be used with query module, activerecord plugin, and any other add-on that outputs raw channel data.

Since your problem was that a plugin was outputting raw results from the DB, it looks like it would be the perfect fit and would allow you to get rid of that PHP code

  • I added an inline code example to this post in the hopes that it helps someone. It is very simple to use.
    – tatlar
    Commented Jan 23, 2015 at 22:25
  • @robson-sobral: why did you over-ride/edit my simple inline code example with a bunch of extraneous code???? Your edit does not make any sense? Here is my original edit for future reference: {exp:parse_file_paths}{filedir_X}{/exp:parse_file_paths}
    – tatlar
    Commented Jan 26, 2015 at 18:07
  • Just to make clear that you can parse all the content at once, which is faster than one by one. I'm sorry. I gonna bring it back.
    – Sobral
    Commented Jan 26, 2015 at 21:02

In the end I found it was wrapped in a custom plugin which was taking the results directly from the exp_channel_data table. I'm not sure why EE suddenly decided to stop parsing filedir_3 but I added the following if statement into the code as a bit of a bodge and it's working fine now.

for($i=0;$i<$data_row_count;$i++) { // for every row
    if (isset($vars['download_details']))
        $vars['download_details'] = str_replace('{filedir_3}','/uploads/',$vars['download_details']);
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables) ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.