Support » Plugin: Meta Box » Display file uploads

  • Resolved Emiline220

    (@emiline220)


    I’m trying to get a file upload to display (using the regular file upload, not advanced) and I used the exact code that’s on the documentation page, but I’m getting an error.

    Here’s the code I’m using:

    $files = rwmb_meta( 'ks_file' ); // Since 4.8.0
        if ( !empty( $files ) ) {
            foreach ( $files as $file ) {
                echo "<a title="{$file[" href="{$file[">{$file['name']}</a>";
            }
        } 

    Here’s the error I’m getting:

    Parse error: syntax error, unexpected ‘{‘, expecting ‘,’ or ‘;’

    It seems to be the fourth line that’s causing the issue, but I don’t know how to modify it to make it display correctly.

Viewing 1 replies (of 1 total)
  • Plugin Author Tran Ngoc Tuan Anh

    (@rilwis)

    Hi Emiline,

    The code is incorrect. The correct one is:

    $files = rwmb_meta( 'info' ); // Since 4.8.0
    $files = rwmb_meta( 'info', 'type=file' ); // Prior to 4.8.0
    
    if ( !empty( $files ) ) {
        foreach ( $files as $file ) {
            echo "<a title="{$file['name']}" href="{$file['url']}">{$file['name']}</a>";
        }
    }

    I updated the documentation as well.

Viewing 1 replies (of 1 total)
  • The topic ‘Display file uploads’ is closed to new replies.