Reputation: 23
Someone can help me please with this code? I would add multiple images but I can't figure it out. I tried the multiple command but it doesn't worked, I have no clue honestly.
HTML code:
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data" data-abide>
<div class="photo-field">
<input type="file" name="file_img" pattern="^.+?\.(jpg|JPG|png|PNG|jpeg|JPEG)$" required>
<small class="error">Upload JPG or PNG only.</small>
</div>
<div class="title-field">
<input type="text" name="img_title" placeholder="Image title" required>
<small class="error">Image title is required.</small>
</div>
<input type="submit" value="Upload Image" name="btn_upload" class="button">
</form>
PHP code:
<li><a href="upload-photo.php" data-reveal-id="uploadModal" data-reveal-ajax="true">Add Photo</a></li>
<li class="divider"></li>
</ul>
</section>
</nav>
<br/>
<!--Content goes here-->
<div class="row">
<div class="large-12 columns">
<?php
if(isset($_GET['success'])) {
if($_GET['success']=="yes"){?>
<div class="row">
<div class="small-6 large-6 columns">
<div data-alert class="alert-box success radius ">
Image "<?= $_GET['title']; ?>" uploaded successfully.
<a href="#" class="close">×</a>
</div>
</div>
</div>
<?php } else {?>
<div class="row">
<div class="small-6 large-6 columns">
<div data-alert class="alert-box alert radius ">
There was a problem uploading the image.
<a href="#" class="close">×</a>
</div>
</div>
</div>
<?php } }?>
Upvotes: 1
Views: 303
Reputation: 753
The problem is, that there is no loop in the processing php script.
So only one file gets uploaded.
For more info and solutions see: Multiple file upload in php
Upvotes: 2