PHP Jquery Ajax Upload Multiple Images with Preview

JavaScript jQuery Mysql php Programming

Today, We want to share with you PHP Jquery Ajax Upload Multiple Images with Preview Example.In this post we will show you multiple image upload in laravel using ajax, hear for multiple image upload in php with database we will give you demo and example for implement.In this post, we will learn about multiple image upload with preview and delete jquery php with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

PHP Jquery Ajax Upload Multiple Images with Preview Example

There are the Following The simple About PHP Jquery Ajax Upload Multiple Images with Preview Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to upload multiple images in php using for loop, so the some image upload using ajax php mysql for this example is following below.

Step 1 : Javascript Code:

jQuery Source code

            $('#status').html('<img src="image.gif"/>');
            $('#status').html('Sorry Your products_img uploading failed, please try again.');

Step 2 : HTML Code:

HTML Source Code:

<form method="post" id="submitForm" enctype="multipart/form-data" action="upload.php">
    <label>Choose products_img</label>
    <input type="file" name="products_img[]" id="imgs" multiple >
    <input type="submit" name="submit" value="UPLOAD"/>
<div id="status"></div>

<div class="gallery" id="products_imgPrev"></div>

Step 3 : PHP Source Code:

PHP Code: (upload.php)


    $target_dir = "uploads/";
    $allow_types = array('jpg','png','jpeg','gif');
    $products_img_arr = array();
    foreach($_FILES['products_img']['name'] as $key=>$val){
        $image_name = $_FILES['products_img']['name'][$key];
        $tmp_name   = $_FILES['products_img']['tmp_name'][$key];
        $size       = $_FILES['products_img']['size'][$key];
        $type       = $_FILES['products_img']['type'][$key];
        $error      = $_FILES['products_img']['error'][$key];
        $file_name = basename($_FILES['products_img']['name'][$key]);
        $uploadFileImgDir = $target_dir . $file_name;
        $file_type = pathinfo($uploadFileImgDir,PATHINFO_EXTENSION);
        if(in_array($file_type, $allow_types)){    
                $products_img_arr[] = $uploadFileImgDir;
    if(!empty($products_img_arr)){ ?>
        <?php foreach($products_img_arr as $image_src){ ?>
            <li><img src="<?php echo $image_src; ?>" alt=""></li>
        <?php } ?>
<?php }

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Jquery Ajax Upload Multiple Images with Preview Example.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   VueJS Hello World First Application
  2.   Ajax Upload Multiple Images without form submitting
  3.   vuejs Simple calculator web Application
  4.   Bootstrap 5 star rating Example
  5.   jQuery Ajax File Upload images using PHP MySQLi
  6.   Ajax Image Upload using PHP and jQuery
  7.   How to create a log file PHP Yii Framework
  8.   Increment Decrement with Laravel 6 Example
  9.   How to Write PHP Code in Laravel Blade?
  10.   PHP list files in directory by date descending

Leave a Reply

Your email address will not be published. Required fields are marked *