-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
36 lines (31 loc) · 880 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
<?php
session_start();
if(isset($_FILES["image"])){
require_once "convert.php";
function rand_string($length) {
$str="";
$chars = "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen($chars);
for($i = 0;$i < $length;$i++) {
$str .= $chars[rand(0,$size-1)];
}
return $str;
}
/**
* If image is not valid, output a default image
* @var [type]
*/
$sourceImg = @imagecreatefromstring(@file_get_contents($_FILES["image"]["tmp_name"]));
if ($sourceImg === false){
echo "images/default-profile-pic.png";
exit;
}
$image = makeDP($_FILES["image"]["tmp_name"], (
isset($_POST["design"]) ? $_POST["design"] : 0
));
$loc = "uploads/" . rand_string(10) . ".png";
file_put_contents($loc, $image);
$_SESSION['loc'] = $loc;
imagedestroy($dest);
imagedestroy($src);
}