MySQL interesse |
|
Naar aanleiding van http://www.site..._aangeduid had ik nog een vraag:
Ik heb een pagina waar je 4 foto's kunt uploaden. Maar als er maar 3 geupload worden, wil ik ook dat er maar 3 getoond worden.
html-code:
<input type="file" name="pictures[]" /><br>
<input type="file" name="pictures[]" /><br>
<input type="file" name="pictures[]" /><br>
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" /><br> <input type="file" name="pictures[]" /><br> <input type="file" name="pictures[]" /><br> <input type="file" name="pictures[]" />
doorsturen:
$files = array();
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "images/$name");
array_push($files, $name);
}
}
foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; } }
De 4 files worden weergegeven als $file1, $file2, $file3 en $file4
|