-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuploadImage.php
85 lines (55 loc) · 1.71 KB
/
uploadImage.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
* Get all names of images and store in array
* Upload images to server (in /Photos dir)
* Update database with status, image path(s)
*
* (How to make sure that image names can be same in /Photos dir?)
* Link image with status ID ("SELECT last_insert_id()") check https://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
*
* */
// upload image and status
function uploadImage(){
// get image names
if(isset($_FILES['fileToUpload']) ) {
$index=0;
$uploads = false;
foreach ($_FILES['fileToUpload']['tmp_name'] as $key => $tmp_name) {
if (!empty($_FILES['fileToUpload']['tmp_name'][$key])) {
// what to do with each image
$filename = $_FILES["fileToUpload"]["name"][$index];
echo "file " . $filename . " uploaded <br/>";
//echo $filename. "<br/>";
$index++;
$uploads = true;
}
}
} else {
echo "no file uploaded";
}
if ($uploads == false){
echo "no file uploaded";
}
}
function image_present(){
if(isset($_FILES['fileToUpload']) ) {
$index=0;
$uploads = false;
foreach ($_FILES['fileToUpload']['tmp_name'] as $key => $tmp_name) {
if (!empty($_FILES['fileToUpload']['tmp_name'][$key])) {
$filename = $_FILES["fileToUpload"]["name"][$index];
//echo "file " . $filename . " uploaded <br/>";
$index++;
$uploads = true;
return true;
}
}
} else {
//echo "no file uploaded";
return false;
}
if ($uploads == false){
return false;
}
}
?>