-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupload.php
More file actions
28 lines (23 loc) · 843 Bytes
/
upload.php
File metadata and controls
28 lines (23 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
function random_string($length) {
$key = '';
$keys = array_merge(range(0, 9), range('a', 'z'));
for ($i = 0; $i < $length; $i++) {
$key .= $keys[array_rand($keys)];
}
return $key;
}
$ds = DIRECTORY_SEPARATOR;
$storeFolder = 'uploads';
if (!empty($_FILES)) {
$fileName = $_FILES['file']['name'];
$tempFile = $_FILES['file']['tmp_name'];
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
$targetPath = dirname( __FILE__ ) . $ds . $storeFolder . $ds;
list($width, $height, $type, $attr) = getimagesize($tempFile);
//$targetFile = $targetPath . $_FILES['file']['name'];
//$targetFile = $targetPath . time() . "_" . random_string(5) . "." . $ext;
$targetFile = $targetPath . time() . "_" . random_string(5) . "_" . $width . "_" . $height . "." . $ext;
move_uploaded_file($tempFile,$targetFile);
}
?>