-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
63 lines (54 loc) · 1.9 KB
/
upload.php
File metadata and controls
63 lines (54 loc) · 1.9 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
session_start();
require_once('./elements//header_allowed.php');
require_once('./config/config.php');
require_once('./elements/helpers.php');
if (!empty($_FILES)) {
$ds = DIRECTORY_SEPARATOR;
$storeFolder = 'public';
$tempFile = $_FILES['file']['tmp_name'];
$image = new Imagick($_FILES['file']['tmp_name']);
$image->scaleImage(420, 420, 0);
$image->setImageFormat( "jpg" );
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds . $_SESSION['user']['id'] . $ds;
$targetFilename = md5(time()) . ".jpg";
Image::uploadByUser($_SESSION['user']['id'], $targetFilename, $_FILES['file']['tmp_name']);
$image->writeImage($targetPath . $targetFilename);
return;
}
$u = User::userById($_SESSION['user']['id']);
$title = ucfirst($u['username']);
?>
<!DOCTYPE html>
<html>
<?php include('./elements/header.php'); ?>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.css"/>
<body>
<?php include('./elements/nav.php'); ?>
<section class="section">
<div class="columns is-mobile">
<div class="box column is-half-desktop is-three-quarters-tablet container upload-container">
<form action="/upload.php" method="POST" class="dropzone dz-clickable" id="myAwesomeDropzone" style="border: none">
<div class="upload-block media ">
<p class="icon" style="margin: 0 auto;"><i class="fa fa-upload" style="font-size: 36px"></i></p>
</div>
</form>
</div>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
<script>
Dropzone.options.myAwesomeDropzone = {
paramName: "file",
maxFilesize: 2,
accept: function(file, done) {
// call done with arg to cancel upload
done();
setTimeout(function() {
window.location.href = '/profile.php';
}, 500);
}
};
</script>
</body>
</html>