-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc7.php
30 lines (26 loc) · 811 Bytes
/
c7.php
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
29
30
<?php
// print_r($_POST);
// print_r($_FILES);
if(isset($_FILES['slika'])){
$broj = count($_FILES['slika']['name']);
for($i = 0; $i < $broj; $i++){
$types = ['image/jpeg', 'image/png', 'image/gif'];
$size = 1024 * 1024 * 2;
if(in_array($_FILES['slika']['type'], $types) && $_FILES['slika']['size'] < $size && $_FILES['slika']['error'] == 0){
$r = rand(1000000000, 9999999999);
$upload_dir = 'uploads/';
$file_name = $_FILES['slika']['name'];
$temp_location = $_FILES['slika']['tmp_name'];
$new_location = $upload_dir.$r.'_'.$file_name;
if(move_uploaded_file($temp_location, $new_location)){
echo "Upload successfull";
} else {
echo "Upload failed by unknown reason!";
}
} else {
echo "File does not fit the criteria!";
} else {
echo "No file was attached for upload";
}
}
?>