-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccept-file.php
More file actions
31 lines (27 loc) · 1.16 KB
/
accept-file.php
File metadata and controls
31 lines (27 loc) · 1.16 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
<?php
// include ImageManipulator class
require_once('ImageManipulator.php');
if ($_FILES['fileToUpload']['error'] > 0) {
echo "Error: " . $_FILES['fileToUpload']['error'] . "<br />";
} else {
// array of valid extensions
$validExtensions = array('.jpg', '.jpeg', '.JPG', '.JPEG', '.GIF', '.PNG', '.gif', '.png');
// get extension of the uploaded file
$fileExtension = strrchr($_FILES['fileToUpload']['name'], ".");
// check if file Extension is on the list of allowed ones
if (in_array($fileExtension, $validExtensions)) {
$newNamePrefix = time() . '_';
$manipulator = new ImageManipulator($_FILES['fileToUpload']['tmp_name']);
// resizing to 200x200
$newImage = $manipulator->resample(800, 600);
// saving file to uploads folder
$filename = $newNamePrefix . $_FILES['fileToUpload']['name'];
$manipulator->save('uploads/' . $newNamePrefix . $_FILES['fileToUpload']['name']);
//echo 'Uploaded: ' . $filename;
$domain = $_SERVER["SERVER_NAME"];
$url = "artedex";
header("Location: .?file=" . $filename);
} else {
echo 'You must upload an image...';
}
}