-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.php
More file actions
44 lines (42 loc) · 1.27 KB
/
index.php
File metadata and controls
44 lines (42 loc) · 1.27 KB
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
39
40
41
42
43
44
<html>
<head>
<title>Wassup</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var image = $('#im').html();
if(image) {
$('#ha').html("<img src='loading.gif' alt='loading' />");
$.get('convert.php?im='+image,function(data){
$('#ha').html(data);
});
}
});
</script>
</head>
<body>
<?php
if(isset($_POST['submit'])){
if(($_FILES['file']['type'] == 'image/png' || $_FILES['file']['type'] == 'image/jpeg') && $_FILES['file']['error'] == 0){
$rand = 'images/';
for($i = 0;$i < 6;$i++)
$rand .= rand() % 10;
// creates random directory and stores image file into it
mkdir($rand);
$image = $rand . "/". $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$image);
echo "<div id='im' style='display:none;'>" . $image . "</div>";
} else {
echo "not supported file type";
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type='file' name='file' /><input type='submit' name='submit' value='Upload' />
</form>
<br /><br />
<div id='ha'>
</div>
</body>
</html>