function makeFileDownloadable($files, $filesize, $user_dir = '', $date) { $arrFiles = explode(',', $files); $uploads = wp_upload_dir(); $html = ''; foreach ($arrFiles as $f) { if (!file_exists($uploads['basedir'] . '/user_uploads/' . $f)) { $urlDownload = $uploads['baseurl'] . '/user_uploads/' . $user_dir . '/' . $f; } else { $urlDownload = $uploads['baseurl'] . '/user_uploads/' . $f; } $html .= '<a href="' . $urlDownload . '" title="' . $f . '" class="nm-link-title" target="_blank">' . $f . ' (' . nmFileUploader::sizeInKB($filesize) . ')</a>'; } $html .= ' - <span class="nm-file-meta-more">' . nmFileUploader::time_difference($date) . '</span>'; return $html; }
<?php global $wpdb; /* delete file */ if (isset($_GET['fid'])) { //echo 'file deleted '.nmFileUploader::deleteFile($_GET['fid']); if (nmFileUploader::deleteFile($_GET['fid'])) { echo '<div class="updated">'; echo "<p>" . get_option('nm_file_deleted_msg') . "</p>"; echo '</div>'; } } /*$wpdb->show_errors(); $wpdb->print_error(); */ $arrFiles = nmFileUploader::getAllUserFiles(); ?> <div style="margin:5px;padding:5px;border:1px solid #CCC; background-color:#f5f5f5"> <h3>Total files: <?php echo count($arrFiles); ?> </h3> <div class="user-uploaded-files"> <table width="100%" border="0" id="user-files" class="wp-list-table widefat fixed posts"> <thead> <tr> <th width="233" align="left" valign="middle"><strong>File Name</strong></th> <th width="516" align="left" valign="middle"><strong>Notes</strong></th> <th width="71" align="center" valign="middle"><strong>Date</strong></th> <th width="97" align="center" valign="middle"><strong>Action</strong></th>
*/ if (isset($_GET['fid'])) { if (nmFileUploader::deleteFile(intval($_GET['fid']))) { echo "<div class=\"red\">" . get_option('nm_file_deleted_msg') . "</div>"; } } /*$wpdb->show_errors(); $wpdb->print_error(); */ /* save file */ if (isset($_POST['nm-submit'])) { nmFileUploader::$file_name = sanitize_text_field($_POST['file-name']); nmFileUploader::$desc = sanitize_text_field($_POST['description']); nmFileUploader::$file_type = "." . nmFileUploader::getFileExtension(sanitize_text_field($_POST['file-name'])); if (nmFileUploader::saveFile()) { echo "<div class=\"green\">" . get_option('nm_file_uploaded_msg') . "</div>"; } } ?> <div id="nm-upload-container"> <p style="text-align:center"> <strong><?php _e('Upload file(s):', nmFileUploader::$short_name); ?> </strong> <span style="font-style: italic"><?php _e('click button below and browse for your file(s), then click "Save"', nmFileUploader::$short_name);