Gumbo
Erfahrenes Mitglied
Probier mal Folgendes:
PHP:
<?php
include 'connect.php';
mysql_select_db('galerie') or die('Datenbank konnte nicht ausgewählt werden.');
if( isset($_POST['submit:hochladen']) ) {
foreach( $_FILES['bilder']['error'] as $key => $error ) {
if( $error == UPLOAD_ERR_OK ) {
move_uploaded_file($_FILES['bilder']['tmp_name'][$key], 'phptmp/bilder/'.$_GET['galerie'].'/'.$_FILES['bilder']['name'][$key]);
$query = "
INSERT INTO
`bilder`
SET
`datei` = '".mysql_real_escape_string($_FILES['bilder']['name'][$key])."',
`galerie` = '".mysql_real_escape_string($_GET['id'])."'
";
mysql_query($query);
}
}
}
if( isset($_POST['anzahl']) && (int)$_POST['anzahl'] > 0 ) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<p>Pictures:</p>
<?php
for($i=0; $i<$_POST['anzahl']; $i++) {
echo '<p><input type="file" name="bilder[]"></p>';
}
?>
<p><input type="submit" name="submit:hochladen" value="Hochladen"></p>
</form>
<?php
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p><label for="text:anzahl">Anzahl der hochzuladenen Bilder</label><br>
<input type="text" id="text:anzahl" name="anzahl" size="5"></p>
<p><input type="submit" name="submit:bilderanzahl" value="Senden"><input type="reset" value="Zurücksetzen"></p>
</form>
<?php
}
?>
Zuletzt bearbeitet: