jQuery Ajax Upload Multiple Images using PHP

Today, We want to share with you jQuery Ajax Upload Multiple Images using PHP.In this post we will show you how to insert image in database using ajax in php, hear for ajax multiple file upload form using jquery demo 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.

jQuery Ajax Upload Multiple Images using PHP

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

As I will cover this Post with live Working example to develop upload multiple images in php with preview, so the multiple image upload in php with database for this example is following below.

  Date Range Search Jquery DatePicker using Ajax PHP with MySQL

jQuery Multiple Files Upload Form

JavaScript Source Code:

            $('#file_status').html('<img src="file_loading_uploading.gif"/>');
            $('#file_status').html('More Images upload failed, please try again.');

HTML Source Code:

<!-- pictures upload form -->
<form method="post" id="uploadForm" enctype="multipart/form-data" action="upload.php">
    <label>Choose Images</label>
    <input type="file" name="pictures[]" id="pictures" multiple >
    <input type="submit" name="submit" value="UPLOAD"/>

<!-- display upload status -->
<div id="uploadStatus"></div>

Uploaded Images Preview

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

Download Project Scripts

<!-- gallery view of uploaded pictures --> 
<div class="gallery" id="picturesPreview"></div>

Upload Multiple Images with PHP


    // PHP File upload configuration
    $targetDir = "uploads/";
    $allowTypes = array('jpg','png','jpeg','gif');
    $pictures_arr = array();
    foreach($_FILES['pictures']['name'] as $key=>$val){
        $image_name = $_FILES['pictures']['name'][$key];
        $tmp_name   = $_FILES['pictures']['tmp_name'][$key];
        $size       = $_FILES['pictures']['size'][$key];
        $type       = $_FILES['pictures']['type'][$key];
        $error      = $_FILES['pictures']['error'][$key];
        // File upload path
        $fileName = basename($_FILES['pictures']['name'][$key]);
        $live_imgPath = $targetDir . $fileName;
        // Check whether file type is valid
        $fileType = pathinfo($live_imgPath,PATHINFO_EXTENSION);
        if(in_array($fileType, $allowTypes)){    
            // Store pictures on the server
                $pictures_arr[] = $live_imgPath;
    // Generate powerfule simple all the Display view of the pictures
    if(!empty($pictures_arr)){ ?>
        <?php foreach($pictures_arr as $image_src){ ?>
            <li><img src="<?php echo $image_src; ?>" alt=""></li>
        <?php } ?>
<?php }

PHP upload the pictures as well render the preview

  Simple Ajax Upload image using jQuery PHP

    $pictures_arr = array();
    foreach($_FILES['pictures']['name'] as $key=>$val){
        //preview pictures without stored
        $picture_data_info = getpicturesize($_FILES['pictures']['tmp_name'][$key]);
        $pictures_arr[] = "data:" . $picture_data_info["mime"] . ";base64," . base64_encode(file_get_contents($_FILES['pictures']['tmp_name'][$key]));

Angular 6 CRUD Operations Application Tutorials

Read :


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

I hope you get an idea about jQuery Ajax Upload Multiple Images using PHP.
I would like to have feedback on my Pakainfo.com 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.   PHP Jquery Ajax Upload Multiple Images with Preview
  2.   Jquery check if value exists in Array Example
  3.   Basic OOP PHP CRUD Operation Using MySQLi from Scratch
  4.   Dynamically set active tab in jquery
  5.   jQuery Ajax Multiple File Upload Using PHP
  6.   jquery multiple Image Upload with preview and Delete using PHP
  7.   Dynamically Upload Multiple Images Using PHP and jQuery
  8.   php accelerator xampp install and/or enable
  9.   PHP upload custom file in ckeditor Example
  10.   Ajax Image Upload using PHP and jQuery

Leave a Reply

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