-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceUpload.php
30 lines (24 loc) · 911 Bytes
/
serviceUpload.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
<?php
include 'session.php';
if(isset($_POST['btn-upload'])){
foreach($_POST AS $key => $value) { $_POST[$key] = ($value); }
$imgSize = $_FILES['file']['size'];
$imgErrorCode = $_FILES['file']['error'];
$imgData = addslashes(file_get_contents($_FILES['file']['tmp_name']));
$imageProperties = getimageSize($_FILES['file']['tmp_name']);
$sql = "UPDATE contact_us SET header='{$_POST['header']}', detail='{$_POST['detail']}'
WHERE id = 5";
$sql2 = "INSERT INTO output_images(imageType ,imageData, name, category)
VALUES('{$imageProperties['mime']}', '{$imgData}', 'service', 'service')";
try {
$result = $db->query($sql);
if($imgSize != 0 && $imgErrorCode == 0){ // imgSize not 0 and file not an error
$result2 = $db->query($sql2);
}
}
catch(PDOException $ex){
echo "error cannot change contact us content";
}
header('Location: '.'./uploadServices.php');
}
?>