-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
32 lines (30 loc) · 1.17 KB
/
upload.php
File metadata and controls
32 lines (30 loc) · 1.17 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
<?php
session_start();
require_once('FirePHPCore/FirePHP.class.php');
require_once('FirePHPCore/fb.php');
ob_start();
fb($_FILES, "FILES-Array: ");
// ============================
// Directory "images" not included on github repo.
// ============================
$fileupload=$_FILES['picture'];
$imageSeparated = explode(".", $_FILES['picture']['name']);
$imageExtension = $imageSeparated[1];
$path = "images/" . uniqid() . "." . $imageExtension;
if( !$fileupload['error'] && $fileupload['size']>0
&& $fileupload['tmp_name']
&& is_uploaded_file($fileupload['tmp_name'] )
&& ( ($fileupload['type'] == 'image/jpeg') || ($fileupload['type'] == 'image/gif') || ($fileupload['type'] == 'image/png'))
&& ((strtolower($imageExtension) == 'jpg') || (strtolower($imageExtension) == 'jpeg') || (strtolower($imageExtension) == 'gif') || (strtolower($imageExtension) == 'png'))
&& move_uploaded_file($fileupload['tmp_name'], $path)
)
{
echo "Upload to " . $path . " successful!";
// Can I use header('Location:') like that?
header( 'Location: photoapp.php?upload=true' ) ;
}
else {
echo "No upload for you";
header( 'Location: photoapp.php?upload=false' ) ;
}
?>