Salam, adi contact form hazırlamışam, ona multi upload quşmaq istəyirəm. bunu necə edə bilərəm? ya da hazır multi upload dəstəyi olan contact form bilirsiniz?
Salam, adi contact form hazırlamışam, ona multi upload quşmaq istəyirəm. bunu necə edə bilərəm? ya da hazır multi upload dəstəyi olan contact form bilirsiniz?
Verilmiş cavablar və yazılan şərhlər (2 cavab var)
0
Google
http://google.com/search?q=multi+upload+form+script+php
1
1
<?php
2
3
$valid_formats = array("jpg", "png", "gif", "zip", "bmp"); //icaze verilmis farmatlar
4
$max_file_size = 1024*100; //100 kb
5
$path = "uploads/"; // Upload qovluq
6
$count = 0;
7
8
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
9
// Loop $_FILES to execute all files
10
foreach ($_FILES['files']['name'] as $f => $name) {
11
if ($_FILES['files']['error'][$f] == 4) {
12
continue; // Skip file if any error found
13
}
14
if ($_FILES['files']['error'][$f] == 0) {
15
if ($_FILES['files']['size'][$f] > $max_file_size) {
16
$message[] = "$name is too large!.";
17
continue; // Skip large files
18
}
19
elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){
20
$message[] = "$name is not a valid format";
21
continue; // Skip invalid file formats
22
}
23
else{ // No error found! Move uploaded files
24
if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name)) {
25
$count++; // Number of successfully uploaded files
26
}
27
}
28
}
29
}
30
}
31
?>
32
33
<!doctype html>
34
<html lang="en">
35
<head>
36
<meta charset="UTF-8" />
37
<title>Multiple File Upload with PHP - Demo</title>
38
<style type="text/css">
39
a{ text-decoration: none; color: #333}
40
h1{ font-size: 1.9em; margin: 10px 0}
41
p{ margin: 8px 0}
42
*{
43
margin: 0;
44
padding: 0;
45
box-sizing: border-box;
46
-webkit-box-sizing: border-box;
47
-moz-box-sizing: border-box;
48
-webkit-font-smoothing: antialiased;
49
-moz-font-smoothing: antialiased;
50
-o-font-smoothing: antialiased;
51
font-smoothing: antialiased;
52
text-rendering: optimizeLegibility;
53
}
54
body{
55
font: 12px Arial,Tahoma,Helvetica,FreeSans,sans-serif;
56
text-transform: inherit;
57
color: #333;
58
background: #e7edee;
59
width: 100%;
60
line-height: 18px;
61
}
62
.wrap{
63
width: 500px;
64
margin: 15px auto;
65
padding: 20px 25px;
66
background: white;
67
border: 2px solid #DBDBDB;
68
-webkit-border-radius: 5px;
69
-moz-border-radius: 5px;
70
border-radius: 5px;
71
overflow: hidden;
72
text-align: center;
73
}
74
.status{
75
/*display: none;*/
76
padding: 8px 35px 8px 14px;
77
margin: 20px 0;
78
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
79
color: #468847;
80
background-color: #dff0d8;
81
border-color: #d6e9c6;
82
-webkit-border-radius: 4px;
83
-moz-border-radius: 4px;
84
border-radius: 4px;
85
}
86
input[type="submit"] {
87
cursor:pointer;
88
width:100%;
89
border:none;
90
background:#991D57;
91
background-image:linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
92
background-image:-moz-linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
93
background-image:-webkit-linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
94
color:#FFF;
95
font-weight: bold;
96
margin: 20px 0;
97
padding: 10px;
98
border-radius:5px;
99
}
100
input[type="submit"]:hover {
101
background-image:linear-gradient(bottom, #9C215A 0%, #A82767 52%);
102
background-image:-moz-linear-gradient(bottom, #9C215A 0%, #A82767 52%);
103
background-image:-webkit-linear-gradient(bottom, #9C215A 0%, #A82767 52%);
104
-webkit-transition:background 0.3s ease-in-out;
105
-moz-transition:background 0.3s ease-in-out;
106
transition:background-color 0.3s ease-in-out;
107
}
108
input[type="submit"]:active {
109
box-shadow:inset 0 1px 3px rgba(0,0,0,0.5);
110
}
111
</style>
112
113
</head>
114
<body>
115
<div class="wrap">
116
<h1><a href="http://www.w3bees.com/2013/02/multiple-file-upload-with-php.html">Multiple File Upload with PHP</a></h1>
117
<?php
118
# error messages
119
if (isset($message)) {
120
foreach ($message as $msg) {
121
printf("<p class='status'>%s</p></ br>\n", $msg);
122
}
123
}
124
# success message
125
if($count !=0){
126
printf("<p class='status'>%d files added successfully!</p>\n", $count);
127
}
128
?>
129
<p>Max file size 100kb, Valid formats jpg, png, gif</p>
130
<br />
131
<br />
132
<!-- Multiple file upload html form-->
133
<form action="" method="post" enctype="multipart/form-data">
134
<input type="file" name="files[]" multiple="multiple" accept="image/*">
135
<input type="submit" value="Upload">
136
</form>
137
</div>
138
</body>
139
</html>
Sual verin
Cavab verin