function wpcloud_upload() { $upload_directory = ABSPATH . 'cloud/' . get_current_user_id() . '/'; if (!(file_exists($upload_directory))) { mkdir(ABSPATH . 'cloud/' . get_current_user_id(), 0775, true); } //Check for allowed extension $temp1 = explode(".", $_FILES["file"]["name"]); $extension = end($temp1); if (!in_array($extension, getAllowedExtensions())) { die('File extension not supported'); } $temp = explode(".", $_FILES["file"]["name"]); $size_MB = $_FILES["file"]["size"] / 1000000; $size_MB = substr($size_MB, 0, 4); $can_UPLOAD = wpcloud_can_upload($size_MB, get_current_user_id()); if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else if ($can_UPLOAD==false) { echo 'Allowed space terminated for this account'; } else { if (file_exists($upload_directory . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists."; } else { move_uploaded_file($_FILES["file"]["tmp_name"], $upload_directory . $_FILES["file"]["name"]); } } }
echo '<table style="width:100%"> <table style="width:100%"> <tr> <th>File name</th> <th>Size</th> <th>Last edit</th> <th></th> </tr>'; while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { //Check file extension == $temp = explode(".", $entry); $extension = end($temp); if (!in_array($extension, getAllowedExtensions())) { continue; } // ==== $file = $dir . '/' . $entry; $file_url = get_site_url() . '/cloud/' . get_current_user_id() . '/' . $entry; echo '<tr>'; echo '<td><a '; echo 'class="wpcloud-file mime-' . getMimeType($file) . '" '; echo 'href="' . $file_url . '" title="' . $entry . '">' . $entry . '</a></td>'; echo '<td><small>' . wpcloud_format_size($file, false) . '</small></td>'; echo '<td><small>' . date("j M Y", filemtime($file)) . '</small></td>';