guillermo_rojas's avatar

Can't capture Image with Dropzone.js

Hi everyone. Once again, I'm stucked and I need some help.

I'm making a upload onto local server with a form. This form has a lot of inuts such as name, street name, bla bla bla, and a file input, wich I want to upload about 5 pictures of that prouct.

I want to make it with Drozone.js

My view

{!! Form::open(['route' =>'admin.properties.store', 'method' => 'POST', 'class' => 'dropzone', 'id' => 'my-awesome-dropzone', 'files' => true ]) !!}
{{-- More inputs --}}
{{-- More inputs --}}
{{-- More inputs --}}

<div class="form-group">
    {!! Form::label('photos', 'Fotos')!!}
    {!! Form::file('photos[]', ['multiple' => 'multiple']) !!}
</div>


<div class="form-group">
    {!! Form::submit('Save', ['class' => 'btn btn-success'])!!}
</div>
{!! Form::close() !!}

@push('javascripts')
    <script src="{!! asset('bower_resources/dropzone/dist/dropzone.js') !!}"></script>
    <script>
        Dropzone.options.myAwesomeDropzone = {
            maxFilesize: 5,
            acceptedFiles: ".jpeg,.jpg,.png,.gif",
            addRemoveLinks: true,
            dictRemoveFile: 'Remover foto',
            dictDefaultMessage: "Arrastre las fotos que desea subir aquí.",
            dictFallbackMessage: "Tu navegador no soporta arrastrar y soltar fotos",
            dictFallbackText: "Por favor, use el boton de seleeccionar fotos",
            dictInvalidFileType: "No puedes subir archivos de este tipo.",
            dictCancelUpload: "Cancelar subida",
            dictCancelUploadConfirmation: "¿Está seguro que quiere cancelar esta subida?",
            dictMaxFilesExceeded: "No puedes subir más archivos.",
            paramName : "photos"
        };
    </script>
@endpush

I drag and drope, serveral photos, but when I click the submit button and in my controller

My controller

class PropertyController extends Controller{
    public function store(Request $request){
        dd($request->photos); // null
    }
}

it returns null.

My code works, as soon as I remove the dropzone stuff, and uploads file "the old fashion way" (ugly without a thumbnail previuos upload)

Why dropzone is not working how it is supossed to be?

0 likes
1 reply
robrogers3's avatar

your not getting any request->photos right (also, you can't really dd here, it's ajax)

i've had problems renaming the param to say photos I just kept it default as files or whatever and it works fine. try it.

Please or to participate in this conversation.