简体   繁体   中英

JQUERY Javascript, post images php

I have this input field where I can upload multiple pictures. I want to send these images to my php side where I upload these pictures to my pictures directory. It does work but for some reason on bigger pictures the information I need on my php side isn't send over to my php side and I don't understand why. Any help would be appreciated. This is my code. When I echo tmp_name and name for a bigger file I only get the name as result but for a smaller file I get the tmp_name and the name of the file for instance big file. Why don't I get the temp filename/location for the bigger files and how can I remedy this?

upload1small

echo $fileName1['tmp_name']; 
echo $fileName1['name']; 

result C:\\Windows\\Temp\\phpE7CF.tmp potd-husky_3235255k.jpg

upload2big

echo $fileName1['tmp_name']; 
echo $fileName1['name']; 

result lion.jpg

<input id=\"file-input\" type=\"file\" multiple>
<div id=\"preview\"></div>
<div> <button class='btn btn-default btn-sm toevoegen' onclick='uploadpic(".$deal_id.");'> toevoegen </button> <button class='btn btn-default btn-sm' onclick='hidephotoupload();'> Annuleren </button>

    function uploadpic(id){
        var data = []
        var data = new FormData();
        jQuery.each(jQuery('#file-input')[0].files, function (i, file) {
            data.append('file-' + i, file);
        });
        $.ajax({
                url: 'dealimage.php?id='+id,
                cache: false,
                contentType: false,
                processData: false,
                type: 'POST',
                data: data
        });
        setTimeout( function(){
            $('#test').load('loaddeal.php?l=LoadDeal&dealid='+id);
        }  , 200 );
    }

Then on the php side I have this:-

if(isset($_FILES['file-0']['name'])){
$fileName[] = $_FILES['file-0'];

}
if(isset($_FILES['file-1']['name'])){
$fileName[] = $_FILES['file-1'];

}
if(isset($_FILES['file-2']['name'])){
$fileName[] = $_FILES['file-2'];

}
if(isset($_FILES['file-3']['name'])){
$fileName[] = $_FILES['file-3'];

}
if(isset($_FILES['file-4']['name'])){
$fileName[] = $_FILES['file-4'];

}
if(isset($_FILES['file-5']['name'])){
$fileName[] = $_FILES['file-5'];

}
if(isset($_FILES['file-6']['name'])){
$fileName[] = $_FILES['file-6'];


}
if(isset($_FILES['file-7']['name'])){
$fileName[] = $_FILES['file-7'];

}

foreach($fileName as $fileName1){

echo $fileName1['tmp_name'];
echo $fileName1['name'];
}

我的 php.ini 的最大上传大小为 2mb,有点遗憾的是人们只知道如何拒绝投票而不是只是帮忙……如果有人想知道打开你的 php.ini 文件并将 upload_max_filesize 更改为你想要的数量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM