How to show the uploaded file name to the user?
After the users have uploaded the file, is there a way to show the file that they have uploaded under the profile?
Currently it is just upload, but I am thinking of showing the file name that they have uploaded earlier on the profile.
Code: Select all
if ( isset($_FILES['tb-documents']) ) {
$documents = $_FILES['tb-documents'];
foreach ( $documents['name'] as $key => $value ) {
if ( $documents['name'][$key]) {
$document = array(
'name' => $documents['name'][$key],
'type' => $documents['type'][$key],
'tmp_name' => $documents['tmp_name'][$key],
'error' => $documents['error'][$key],
'size' => $documents['size'][$key]
);
$status = wp_handle_upload($document, array('test_form' => false));
if( !isset($status['error']) ) {
$uploads = wp_upload_dir();
add_user_meta($user->ID, 'tb-documents', $uploads['url'].'/'.basename($status['file']));
}
}
}
}Code: Select all
if ( !empty($documents) ) {
for ( $y = 0; $y < count($documents); $y++ ) {
$content .= '<br><a href="' . $documents[$y] . '#">Download Document #' . ($y+1) . '</a> (<a href="?page=tb-tutors&id=' . $user->ID . '&delete=' . esc_attr(basename($documents[$y])) . '">Delete</a>)';
}
}Which variable should I use?
Please advice.