Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在laravel中上载带有FormData的文件时输入为空_Javascript_Php_Jquery_Laravel_File Upload - Fatal编程技术网

Javascript 在laravel中上载带有FormData的文件时输入为空

Javascript 在laravel中上载带有FormData的文件时输入为空,javascript,php,jquery,laravel,file-upload,Javascript,Php,Jquery,Laravel,File Upload,我使用的是Laravel5.2php5.6fpm。我有表格可以上传视频文件。如果我上传小视频,它会上传文件并显示其余的输入,但如果我尝试上传一个更大的视频(例如4MB),整个输入都是空的,它只会返回null。因此,没有提供任何输入 我的php.ini upload_max_filesize = 200M post_max_size = 200M memory_limit = 800M # increased it, just to make sure its not causing the pr

我使用的是Laravel5.2php5.6fpm。我有表格可以上传视频文件。如果我上传小视频,它会上传文件并显示其余的输入,但如果我尝试上传一个更大的视频(例如4MB),整个输入都是空的,它只会返回
null
。因此,没有提供任何输入

我的php.ini

upload_max_filesize = 200M
post_max_size = 200M
memory_limit = 800M # increased it, just to make sure its not causing the problem
我重申了服务器、nginx、phpfpm进程、清除了缓存,但都是一样的。 我用js
FormData发送数据

$("input.uploaded_photos,input.uploaded_videos").change(function(){
        var input = this;
        var albumId = $("[name='id']").val();
        var albumType = $("[name='type']:checked").val();
        //only continue if currently selected album type matches the current input field

        if($(input).attr('data-type') == albumType){
            if (input.files && input.files.length) {
                var selectedType = $(input).parents('form').find("[name='type']:checked").val();
                var existingUploads = $('.selling-album-upload-' + selectedType + 's-row .selling-album-upload').length;
                var totalResultingUploads = input.files.length + existingUploads;
                var selectedPackCount = parseInt($(input).parents('form').find("[name='picture_pack']").val());
                var dataform = new FormData();
                for(var iFile in input.files){
                    if(!isNaN(iFile)){//otherwise we'll get 'length' and 'file' as keys too
                        var file = input.files[iFile];
                        dataform.append(input.name, file, file.name);
                    }
                }
                dataform.append('album_id', albumId);
                dataform.append('type', albumType);

                $.ajax({
                    url: '/myurl'
                    type: 'POST',
                    data: dataform,
                    async: false,//false, otherwise it creates a GET Request
                    success: function (data) {
                        // do something
                    },
                    cache: false,
                    contentType: false,
                    processData: false
                });
            }
        }
    });
如果我上传'large'video
Input::all()
返回null,为空,我认为问题应该出在js中。下面是php代码:

public function postAddSellingAlbumUpload(){
    $album_id = Input::get('album_id');
    $type = Input::get('type');
    $existing_uploads = Session::get('agent_selling_uploaded_$type'.'s', []);
    $new_uploads = [];
    $posted_files = Input::file('uploaded_'.$type.'s');


    foreach($posted_files as $posted_file){
        $path = '/uploads/tmp/'.uniqid().'.'.Userimage::guessExtension($posted_file->path());
        File::copy($posted_file->path(), public_path().$path);
        $posted_file_id = uniqid();
        $new_uploads[$posted_file_id] = [
            'id' => $posted_file_id,
            'album_id' => $album_id,
            'type' => $type,
            'path' => $path,
        ];
    }
    Session::put('agent_selling_uploaded_$type'.'s', array_merge($existing_uploads, $new_uploads));

    return response()->json([
        'success' => true,
        'uploads' => $new_uploads,
    ]);
}

同样,只有上传“大”文件时才会出现问题。如果文件较小,则一切正常。问题似乎是关于
upload\u max\u filesize
的,但我正确设置了配置文件最后发现,我的操作系统上有多个php版本,其中一个(正在运行)有
upload\u max\u filesize=2M
post\u max\u size=8M