Hi I'm trying to upload multiple files(with array) and it doesn't works..
When I upload just 1 files it works fine, but when I choose more than 1 file it doesn't upload them corectly beacause it creates the files with names and extensions corectly but there size is 0 bytes.
Here is My Code:
$count = 0;
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
foreach ($_FILES['file']['name'] as $i => $name) {
if (strlen($_FILES['file']['name'][$i]) > 1) {
if (move_uploaded_file($_FILES['file']['tmp_name'][$i], 'upload/'.$name)) {
$count++;
}
}
}
}
$count = 0;
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
for ($i=0;$i<count($_FILES['file']);$i++) {
if (strlen($_FILES['file']['name'][$i]) > 1) {
if (move_uploaded_file($_FILES['file']['tmp_name'][$i], 'upload/'.$name)) {
$count++;
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.