-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
32 lines (26 loc) · 1005 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
<?php
include 'session.php';
if(isset($_POST['btn-upload'])){
foreach($_POST AS $key => $value) { $_POST[$key] = ($value); }
$id = 0;
$imgData = addslashes(file_get_contents($_FILES['file']['tmp_name']));
$imageProperties = getimageSize($_FILES['file']['tmp_name']);
$sql = "INSERT INTO output_images(imageType ,imageData, name, category)
VALUES('{$imageProperties['mime']}', '{$imgData}', '{$_POST['name']}', '{$_POST['category']}')";
$sqlnext = "SELECT * FROM output_images
WHERE name = '{$_POST['name']}' and category = '{$_POST['category']}'";
try {
$result = $db->query($sql);
$resultnext = $db->query($sqlnext);
$dbResultx = ($resultnext->rowCount() > 0) ? true : false;
if($dbResultx){
$row = $resultnext->fetch(PDO::FETCH_ASSOC);
$id = $row['imageId'];
}
}
catch(PDOException $ex){
echo "error cannot add item";
}
header('Location: '.'./editProducts.php?id='.$id);
}
?>