. */ // ============== Configuration begin ============== $settings = array( // Directory to store uploaded files uploaddir => '.', // Display list uploaded files listfiles => true, // Display file sizes listfiles_size => true, // Display file dates listfiles_date => true, // Display file dates format listfiles_date_format => 'F d Y H:i:s', // Randomize file names (number of 'false') random_name_len => 10, // Keep filetype information (if random name is activated) random_name_keep_type => true, // Random file name letters random_name_alphabet => 'qwertyuiodfgjkcvbnm', // Display debugging information debug => false ); // ============== Configuration end ============== $data = array(); // Name of this file $data['scriptname'] = pathinfo(__FILE__, PATHINFO_BASENAME); // URL to upload page $data['pageurl'] = "http" . (($_SERVER['SERVER_PORT']==443) ? "s://" : "://") . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']) . '/'; if ($settings['debug']) { // Enabling error reporting error_reporting(E_ALL); error_reporting(1); // Displaying debug information echo '
'; print_r($settings); echo ''; // Displaying debug information echo '
'; print_r($data); echo ''; } function FormatSize ($bytes) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return ceil($bytes) . ' ' . $units[$pow]; } if (isset($_FILES['file']) && strlen($_FILES['file']['name']) > 1) { $data['uploaded_file_name'] = basename($_FILES['file']['name']); $data['target_file_name'] = $data['uploaded_file_name']; if ($settings['random_name_len'] !== false) { $data['target_file_name'] = ''; while (strlen($data['target_file_name']) < $settings['random_name_len']) $data['target_file_name'] .= $settings['random_name_alphabet'][rand(0, strlen($settings['random_name_alphabet']) - 1)]; if ($settings['random_name_keep_type']) $data['target_file_name'] .= '.' . pathinfo($data['uploaded_file_name'], PATHINFO_EXTENSION); } $data['upload_target_file'] = $settings['uploaddir'] . DIRECTORY_SEPARATOR . $data['target_file_name']; $data['tmp_name'] = $_FILES['file']['tmp_name']; if ($settings['debug']) { // Displaying debug information echo '
'; print_r($data); echo ''; } if (move_uploaded_file($data['tmp_name'], $data['upload_target_file'])) { echo $data['pageurl'] . $data['upload_target_file']; exit; // echo 'File: ' . $data['uploaded_file_name'] . ' successfully uploaded: