• Resolved vanduzled

    (@vanduzled)


    I have a loop of file uploads and I want to get just the filename of file uploaded not the whole url where the filename is uploaded.

    For example I uploaded a document file, I want to link to the file and the title of the link is the name of the file.

    word_document_file.doc

    I have this code and this outputs the whole url, not the name of the file.

    <?php
    	if ( CFS()->get('files') ):
    
    	echo "<ul class='small-block-grid-1'>";
    	$cfsloop = CFS()->get('files');
    	foreach ( $cfsloop as $row ) {
    		echo '<li><a href="';
    		echo $row['upload']; // a sub-field named "gallery_title"
    		echo '" class="button">';
    		echo $row['upload'].'</a></li>';
    	}
    	echo "</ul>";
    
    	endif;
    ?>

    https://www.ads-software.com/plugins/custom-field-suite/

Viewing 1 replies (of 1 total)
  • Plugin Author Matt Gibbs

    (@mgibbs189)

    @vanduzled,

    Please rate the plugin if you find it useful. PHP’s basename() function lets you extract just the filename from a directory or URL.

    basename( $row['upload'] );
Viewing 1 replies (of 1 total)
  • The topic ‘How to get the just the filename of the uploaded file’ is closed to new replies.