0

I'm using laravel 5.2 php5.6 fpm. I have form where I can upload video file. everything works fine if I upload small video, it uploads file and show the rest of inputs, but if I try upload a larger video(4MB for example), the WHOLE input is empty, its just returns null. so none of inputs are provided.

my php.ini

upload_max_filesize = 200M
post_max_size = 200M
memory_limit = 800M # increased it, just to make sure its not causing the problem

I restated server, nginx, php-fpm process, cleared cache, but its the same. I send the data with 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
                });
            }
        }
    });

if I upload 'large' video Input::all() returns null, its blank, I think the problem should be in js. anyway here's php code:

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,
    ]);
}

again, the problem happens only if upload 'large' file. if file is small size, everything's ok. its seem like the problem is about upload_max_filesize but I set properly the config file

0

1 Answer 1

1

finally find out, I have multiple php versions on my OS, one of them(which was running) had upload_max_filesize = 2M and post_max_size = 8M that was causing the problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.