Answers for "upload multiple images with same input type with javascript append in php"

PHP
0

upload multiple images in php

extract($_POST);
$error=array();
$extension=array("jpeg","jpg","png","gif");
foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name) {
    $file_name=$_FILES["files"]["name"][$key];
    $file_tmp=$_FILES["files"]["tmp_name"][$key];
    $ext=pathinfo($file_name,PATHINFO_EXTENSION);

    if(in_array($ext,$extension)) {
        if(!file_exists("photo_gallery/".$txtGalleryName."/".$file_name)) {
            move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$file_name);
        }
        else {
            $filename=basename($file_name,$ext);
            $newFileName=$filename.time().".".$ext;
            move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$newFileName);
        }
    }
    else {
        array_push($error,"$file_name, ");
    }
}
Posted by: Guest on November-09-2021
0

upload multiple image using jquery

$('body').on('click', '#upload', function(e){
        e.preventDefault();
        var formData = new FormData($(this).parents('form')[0]);

        $.ajax({
            url: 'upload.php',
            type: 'POST',
            xhr: function() {
                var myXhr = $.ajaxSettings.xhr();
                return myXhr;
            },
            success: function (data) {
                alert("Data Uploaded: "+data);
            },
            data: formData,
            cache: false,
            contentType: false,
            processData: false
        });
        return false;
})
Posted by: Guest on October-27-2020
0

upload multiple file like video or images in php or html with one tag

function reorganize($files) {
    foreach ($files as $var => $params) {
        foreach ($params as $name => $i) {
            foreach ($i as $num => $val) {
                $images[$var][$name] = $val;
                $arr[$num] = $images;
            }
        }
    }
    return $arr;
}

Array (
     [0] => Array ( 
         [image] => Array (
             [name] => white-rabbit-med-crop.jpg
             [type] => image/jpeg 
             [tmp_name] => E:xampptmpphpC008.tmp 
             [error] => 0 
             [size] => 343326 ) 
        ) 
    [1] => Array ( 
         [image] => Array ( 
             [name] => white-rabbit-med-crop.jpg 
             [type] => image/jpeg 
             [tmp_name] => E:xampptmpphpC008.tmp 
             [error] => 0 
             [size] => 1429802 )
        )
)
Posted by: Guest on April-05-2021

Code answers related to "upload multiple images with same input type with javascript append in php"

Browse Popular Code Answers by Language