Home Forums Front-end Issues File download URL incorrect. Cannot download uploaded file.


File download URL incorrect. Cannot download uploaded file.

  • I am trying to download a PDF which has been uploaded through the File Field Type. I’ve followed all the instructions here

    The link is being created but the source of that link is not pointing to the source of the file.


    I am not quite understanding the structure of the URL.

    What is different in my WP setup is the media files are being stored outside of WordPress inside a folder called “files” and perhaps this is what is causing the problem.

    Here’s the code I am using:

    $attachment_id = get_field(‘download_label_afrikaans’);
    $url = wp_get_attachment_url( $attachment_id );
    <?php if( get_field(‘download_label_english’) ): ?>
    “><span></span>Label (ENG)
    <?php endif; ?>

    Thank you.

  • Deleted – one topic at a time

  • Deleted – one topic at a time

  • Hi @sixfootjames

    Your code shows that your image field is returning an ARRAY. Please review the documentation to discover how to output the correct array information.


  • Hi @sixfootjames

    Your first issue can occur when you have updated some, but not all of the WP PATH constants. Please make sure you have correctly set constants for:



  • Hi @elliot

    Thanks for getting back to me. I’ve deleted the two posts that talked about images so as not to confuse matters.

    I’ve since also reverted back to the “wp-content/uploads” folder to simplify matters so I don’t need to worry about the WP PATH constants as mentioned (is my thinking correct?)

    My understanding therefore is as follows:

    • Create Group
    • Create Upload Field
    • In theme page add according to documentation:
      <?php if( get_field('download_label_english') ): ?>
      														<a class="label-en" href="<?php the_field('download_label_english'); ?>"><span></span>Label (ENG)</a>
      													<?php endif; ?>

    But I still get an array URL even though I am not going the array route.

    Many thanks

  • @elliot I have removed my comments about the images. Please delete them and yours if you feel it waters down the main topic. Thanks

  • Right, so what I have done is created a blank WP site. Added ACF, and in my theme page added <a href="<?php the_field('gallery_file'); ?>" >Download File</a> where “gallery_file” is the name of the test field.

    This has worked 100% as expected when a refreshed the page so now I am trying to figure out what I have done wrong with my other project.

    Is it possible that by setting the “wp-content/uploads” to use a different folder by using define( 'UPLOADS', ''.'files' ); I have effectively changed all the paths on a permanent basis and if that is the case, how do I undo this so that it points back to “wp-content/uploads”

  • Finally managed to find the problem!
    In the group the Return Value needs to be File URL rather than File Object which is the default setting under the File Field Type options.

    Many thanks Elliot

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘File download URL incorrect. Cannot download uploaded file.’ is closed to new replies.