Home » jQuery Ajax Upload Multiple Images using PHP

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.

Read Also:  jQuery Ajax Multiple File Upload Using PHP

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.

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

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

Upload Multiple Images with PHP


Read Also:  PHP Remove specific value from array

    // 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

Read Also:  jquery Onmouseover Onmouseout show/hide loop

    $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. Read Also:  Laravel 6 Client Ip Address – How to get Client Ip Address in Laravel 6?
  2. Read Also:  Display Image Preview Before Upload Multiple Images using jQuery,Ajax And PHP
  3. Read Also:  jQuery AJAX file Image upload PHP Example
  4. Read Also:  Remove Yellow BGBOX WordPress plugin
  5. Read Also:  Merge Multiple PHP JSON Array Merge into one array
  6. Read Also:  jQuery AJAX Multiple Files Upload using PHP
  7. Read Also:  PHP and Ajax Asynchronous File Upload using jQuery
  8. Read Also:  Ajax Image Upload using PHP and jQuery
  9. Read Also:  Laravel 6 get ip address Example
  10. Read Also:  jquery multiple Image Upload with preview and Delete using PHP

Leave a Comment

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