listfiles_date_format => 'F d Y H:i:s',
// Randomize file names (number of 'false')
- random_name_len => 4,
+ random_name_len => 8,
// Keep filetype information (if random name is activated)
random_name_keep_type => true,
// Random file name letters
- random_name_alphabet => 'qwertyuiopasdfghjklzxcvbnm',
+ random_name_alphabet => 'qazwsxedcrfvtgbyhnujmikolp1234567890',
// Display debugging information
- debug => ($_SERVER['SERVER_NAME'] === 'localhost')
+ debug => false,
+
+ // Complete URL to your directory (including tracing slash)
+ url => 'http://strace.club/',
);
// 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']) . '/';
-
// Use canonized path
$data['uploaddir'] = realpath($settings['uploaddir']);
return;
}
-
- echo '<pre>';
- print_r($data);
- echo '</pre>';
-
-
if (move_uploaded_file($data['tmp_name'], $data['upload_target_file'])) {
if ($settings['allow_deletion'])
$_SESSION['upload_user_files'][] = $data['target_file_name'];
- echo $data['pageurl'] . $data['upload_target_file'] . "\n";
- // echo 'File: <b>' . $data['uploaded_file_name'] . '</b> successfully uploaded:<br />';
- // echo 'Size: <b>'. number_format($_FILES['file']['size'] / 1024, 3, '.', '') .'KB</b><br />';
- // echo 'File /URL: <b><a href="http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$data['upload_target_file'].'">http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$data['upload_target_file'].'</a></b>';
+ echo $settings['url'] . $data['target_file_name'] . "\n";
} else {
echo 'Error: unable to upload the file.';
}
echo 'File has been removed';
exit;
}
+
+ function ListFiles ($dir, $exclude) {
+ $file_array = array();
+ $dh = opendir($dir);
+ while (false !== ($filename = readdir($dh)))
+ if (is_file($filename) && !in_array($filename, $exclude))
+ $file_array[filemtime($filename)] = $filename;
+ ksort($file_array);
+ $file_array = array_reverse($file_array, true);
+ return $file_array;
+ }
+
?>
<html lang="en-GB">
<head>
<meta charset="utf-8">
- <title>Simple PHP Upload</title>
+ <title>strace.club</title>
+ <style media="screen">
+ body {
+ background: #111;
+ margin: 0;
+ color: #ddd;
+ font-family: sans-serif;
+ }
+
+ h1 {
+ display: block;
+ background: rgba(255, 255, 255, 0.05);
+ padding: 8px 16px;
+ text-align: center;
+ margin: 0;
+ }
+
+ form {
+ display: block;
+ background: rgba(255, 255, 255, 0.075);
+ padding: 16px 16px;
+ margin: 0;
+ }
+
+ p {
+ display: block;
+ background: rgba(255, 255, 255, 0.075);
+ padding: 4px 16px;
+ margin: 16px 0 0 0;
+ text-align: center;
+ }
+
+ ul {
+ display: block;
+ margin: 0;
+ padding: 0;
+ }
+
+ ul > li {
+ display: block;
+ margin: 0;
+ padding: 0;
+ }
+
+ ul > li > a {
+ display: block;
+ margin: 0 0 1px 0;
+ list-style: none;
+ background: rgba(255, 255, 255, 0.1);
+ padding: 8px 16px;
+ text-decoration: none;
+ color: inherit;
+ opacity: 0.5;
+ }
+
+ ul > li > a > span {
+ float: right;
+ font-size: 90%;
+ }
+
+ ul > li > a:hover {
+ opacity: 1;
+ }
+ </style>
</head>
<body>
- <h1>Simple PHP Upload</h1>
- <p>
- Maximum upload size: <?php echo $data['max_upload_size']; ?>
- </p>
+ <h1>strace.club</h1>
<form action="<?= $data['scriptname'] ?>" method="POST" enctype="multipart/form-data" class="dropzone" id="my-awesome-dropzone">
- <div class="fallback">
- Choose File: <input type="file" name="file[]" multiple required /><br />
- <input type="submit" value="Upload" />
- </div>
+ Maximum upload size: <?php echo $data['max_upload_size']; ?><br />
+ <input type="file" name="file[]" multiple required onchange="formname.submit();" />
</form>
<?php if ($settings['listfiles']) { ?>
- <strong>Uploaded files:</strong><br />
+ <p>Uploaded files:</p>
<ul>
<?php
- $dh = opendir($settings['uploaddir']);
- while (false !== ($filename = readdir($dh)))
- if (is_file($filename) && !in_array($filename, array('.', '..', $data['scriptname']))) {
- $file_info = array();
+ $file_array = ListFiles($settings['uploaddir'], array('.', '..', $data['scriptname']));
+ foreach ($file_array as $mtime => $filename) {
+ $file_info = array();
- if ($settings['listfiles_size'])
- $file_info[] = FormatSize(filesize($filename));
+ if ($settings['listfiles_size'])
+ $file_info[] = FormatSize(filesize($filename));
- if ($settings['listfiles_size'])
- $file_info[] = date($settings['listfiles_date_format'], filemtime($filename));
+ if ($settings['listfiles_size'])
+ $file_info[] = date($settings['listfiles_date_format'], $mtime);
- if ($settings['allow_deletion'])
- if (in_array($filename, $_SESSION['upload_user_files']))
- $file_info[] = '<form action="' . $data['scriptname'] . '" method="POST"><input type="hidden" name="target" value="' . $filename . '" /><input type="hidden" name="action" value="delete" /><button type="submit">delete</button></form>';
+ if ($settings['allow_deletion'])
+ if (in_array($filename, $_SESSION['upload_user_files']))
+ $file_info[] = '<form action="' . $data['scriptname'] . '" method="POST"><input type="hidden" name="target" value="' . $filename . '" /><input type="hidden" name="action" value="delete" /><button type="submit">delete</button></form>';
- $file_info = implode(', ', $file_info);
+ $file_info = implode(', ', $file_info);
- if (strlen($file_info) > 0)
- $file_info = ' (' . $file_info . ')';
+ if (strlen($file_info) > 0)
+ $file_info = ' (' . $file_info . ')';
- echo "<li><a href=\"$filename\">$filename</a>$file_info</li>";
- }
+ echo "<li><a href=\"$filename\" target=\"_blank\">$filename<span>$file_info</span></a></li>";
+ }
?>
</ul>
<?php } ?>
+ <a href="https://github.com/muchweb/simple-php-upload"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
</body>
</html>