-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.php
38 lines (29 loc) · 937 Bytes
/
upload.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
31
32
33
34
35
36
37
38
<?php
include 'SimpleImage.php';
if ($_POST['upload']) {
if (empty($_FILES['image']['tmp_name'])) {
header("location: index.php?error=empty");
} else {
$extension = array("jpg", "png");
$file_name=$_FILES["image"]["name"];
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
$only_name = md5($file_name); #uniqid('', false);
$new_name = $only_name.'.'.$ext;
if(in_array($ext,$extension)) {
if(move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/".$new_name)) {
global $success;
$success = 0;
$edit = new SimpleImage('uploads/'.$new_name);
$edit->fit_to_width(800)->save('uploads/'.$new_name);
header("location: data.php?img=".$new_name);
} else {
global $success;
$success = 1;
header("location: index.php?error=fail");
}
}
}
} else {
header("location: index.php");
}
?>