-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestimg.php
81 lines (65 loc) · 2.51 KB
/
testimg.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
<?php
require 'assets/includes/core.inc.php';
require 'assets/includes/connect.php';
function GetImageExtension($imagetype) {
if(empty($imagetype)) return false;
switch($imagetype)
{
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
case 'video/mp4': return '.mp4';
# code...
break;
default: return false;
}
}
if (isset($_POST['upload_images'])) {
if (!empty($_FILES["images"]["name"])){
for ($i=0; $i < count($file_name=$_FILES["images"]["name"]); $i++) {
$temp_name=$_FILES["images"]["tmp_name"][$i];
$file_name=$_FILES["images"]["name"][$i];
$imgtype=$_FILES["images"]["type"][$i];
$ext= GetImageExtension($imgtype);
$imagename= $file_name.$ext;
$target_path = "assets/images/uploads/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {
?>
<script>
window.alert('Multiple Images Uploaded Successfully');
window.history.back();
</script>
<?php
header('LOCATION:index.php');
}else{
?>
<script>
window.alert('Opps! Something Went Wrong in Moving Multiple Images');
window.history.back();
</script>
<?php
header('LOCATION:index.php');
}
}
}
}
?>
<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7 no-js" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8 no-js" lang="en-US">
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html lang="en" class="no-js">
<head></head>
<body>
<div class="col-md-7">
<form action="<?php echo $currentfile ?>" method="post" enctype="multipart/form-data">
<input type="file" name="images[]" multiple>
<button type="submit" name ="upload_images">submit</button>
</form>
</body>
</html>