-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateNews.php
68 lines (58 loc) · 2.09 KB
/
updateNews.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
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
64
65
66
67
68
<?php
include 'session.php';
if(isset($_POST['btn-upload'])){
foreach($_POST AS $key => $value) { $_POST[$key] = ($value); }
$id = 0;
$imgSize = $_FILES['file']['size'];
$imgErrorCode = $_FILES['file']['error'];
$imgData = addslashes(file_get_contents($_FILES['file']['tmp_name']));
$imageProperties = getimageSize($_FILES['file']['tmp_name']);
$imgSize2 = $_FILES['file2']['size'];
$imgErrorCode2 = $_FILES['file2']['error'];
$imgData2 = addslashes(file_get_contents($_FILES['file2']['tmp_name']));
$imageProperties2 = getimageSize($_FILES['file2']['tmp_name']);
$imgSize3 = $_FILES['file3']['size'];
$imgErrorCode3 = $_FILES['file3']['error'];
$imgData3 = addslashes(file_get_contents($_FILES['file3']['tmp_name']));
$imageProperties3 = getimageSize($_FILES['file3']['tmp_name']);
$sql = "INSERT INTO output_images(imageType ,imageData, name, category)
VALUES('{$imageProperties['mime']}', '{$imgData}', 'news1', 'news1')";
$sqlnext = "SELECT * FROM output_images
WHERE name = 'news1' and category = 'news1' ";
$sql2 = "INSERT INTO output_images(imageType ,imageData, name, category)
VALUES('{$imageProperties2['mime']}', '{$imgData2}', 'news2', 'news2')";
$sqlnext2 = "SELECT * FROM output_images
WHERE name = 'news2' and category = 'news2' ";
$sql3 = "INSERT INTO output_images(imageType ,imageData, name, category)
VALUES('{$imageProperties3['mime']}', '{$imgData3}', 'news3', 'news3')";
$sqlnext3 = "SELECT * FROM output_images
WHERE name = 'news3' and category = 'news3' ";
try {
// first item
if($imgSize != 0 && $imgErrorCode == 0){
$result = $db->query($sql);
}
else{
$resultNext = $db->query($sqlnext);
}
// second item
if($imgSize2 != 0 && $imgErrorCode2 == 0){
$result2 = $db->query($sql2);
}
else{
$resultNext2 = $db->query($sqlnext2);
}
// third item
if($imgSize3 != 0 && $imgErrorCode3 == 0){
$result3 = $db->query($sql3);
}
else{
$resultNext3 = $db->query($sqlnext3);
}
}
catch(PDOException $ex){
echo "error cannot add caurosal item";
}
header('Location: '.'./news.php');
}
?>