Laravel和Dropzone上传图片

I have the following code on my view:

<script type="text/javascript">

$("document").ready(function(){

    Dropzone.autoDiscover = false; 

    var myDropzone = new Dropzone("#dropzone", { 
        url: "{{url('subir-foto/'.$publicacion->id)}}",
        maxFilesize: 10,    
        dictDefaultMessage : "Click aquí para subir fotos",
        previewTemplate : '<div style="display:none"></div>',
    });


    myDropzone.on("sending", function(file) {
        $("#progress").show();
        $("#dropzone").hide();          
    });

    myDropzone.on("totaluploadprogress", function(progress) {
        $("#bar").width(progress+'%');
        $("#percent").html(progress.toFixed(2)+'%');
        if (progress==100)
            $("#percent").html('Procesando...');        
    });

    myDropzone.on("queuecomplete", function() {
        $.ajax({
            url: "{{URL::to('fotos/'.$publicacion->id)}}",          
            beforeSend: function(){$("#photos").html('<div class="spinner"></div>');},
            success: function(jsonData) {
              $("#photos").html(jsonData);
            }
        });     
        myDropzone.removeAllFiles(true);
        $("#progress").hide();
        $("#bar").width('0%');
        $("#percent").html("0%");       
        $("#dropzone").show();          
    });     


});

</script>       



<div id="progress" style="display:none" class="progress progress-striped active">
      <div id="bar" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
        <div id="percent"></div>
      </div>
    </div>


<button id="dropzone" class="btn btn-primary" type="submit">Subir fotos</button>

And the controller that receive the image:

    public function storePhoto($id){

    $publicacion = Publicacion::findOrFail($id);

    //AUTENTIFICADORES DE USUARIO
    if(Auth::user()->id!=$publicacion->usuario_id && Auth::user()->perfil->id!=1) return Response::view('errors.401', array(), 401);

    $rules = array(
        'file' => 'required|mimes:jpeg,png,gif|max:10240',
    );
    $validator = Validator::make(Input::all(), $rules);
    if ($validator->fails()){
        return Response::json($validator->messages()->first('file'), 403);
    }       

    $articulo_id = $publicacion->articulo->id;

    $file = Input::file('file');

    $nuevo_nombre = sha1(time().$file->getClientOriginalName()).'.'.$file->getClientOriginalExtension();
    $upload_success = $file->move(upload_path($articulo_id),$nuevo_nombre);

    Image::make(upload_path($articulo_id).$nuevo_nombre)->fit(150, 100)->save(upload_path($articulo_id)."150x100_".$nuevo_nombre);
    Image::make(upload_path($articulo_id).$nuevo_nombre)->resize(450, null, function ($constraint) {$constraint->aspectRatio();$constraint->upsize();})->save(upload_path($articulo_id)."450x300_".$nuevo_nombre);

    $foto = new Foto;
    $foto->articulo_id = $articulo_id;
    $foto->nombre = $nuevo_nombre;
    $foto->save();
    $foto->posicion = Foto::where('articulo_id',$articulo_id)->max('posicion')+1;
    $foto->save();      

    if( $upload_success ) {
        return Response::json('success', 200);
    } else {
        return Response::json('error', 400);
    }
}

The problem is:

When I try to upload many photos, I can only upload a maximum of 5 photos .... In my localhost using WAMP server i haven't this issue. The response is a 500 Error...

Please your feedback.

Best regards

May be you need to increase the execution time for php. Keep this code over top of you php file or update your php ini file.

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

You can also increase the max_file_uploads introduced in Php 5.3.1

Max File Uploads

In case max_file_uploads = 100 doesn't works for you then search for suhosin.upload.max_uploads and set it to

suhosin.upload.max_uploads=100

Hope this helps.