i have a working Dropzone.js
form upload functionality but i decided to change my form like this Dropzone.js Bootstrap demo
if i use the snippets from the demo it's not working or i don't know how to make it work
this is my old working Dropzone.js form code
{!! Form::open(['url' => route('images.store'), 'class' => 'dropzone', 'files'=>true, 'id'=>'real-dropzone', 'name' => 'addimagetoalbum']) !!}
<input type="hidden" name="album_id" value="{{$album->id}}" />
{!! Form::close() !!}
But how can i make it work using the Dropzone.js Bootstrap demo
Thank you in advance.
Related
I have an error in one of my forms, all the others work but in particular I cannot edit in this one since it does not send the post from a form created with Form :: model (), it took me a while to realize that this was the problem, although I have defined the form as POST the data is sent as GET and it does not find the route since it is defined as POST.
This is my failed code:
{!! Form::model($nota, [
'method' => 'POST',
'url' => ['/admin/notas', $nota->id],
'class' => 'form-horizontal',
'files' => true]) !!}
#include('admin.notas.form', ['formMode' => 'edit'])
{!! Form::close() !!}
But later I realized that if I copy the html generated by this code and paste it raw, there it works!
<form method="POST" action="https://mydomain/admin/notas/{{$nota->id}}" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data">
#csrf
#include('admin.notas.form', ['formMode' => 'edit'])
</form>
It is worth mentioning that this form allowed to edit correctly beforehand, and that in localhost (WAMP) it works correctly, I already confirmed that my model, controller and routes are fine, but everything fails from the submit and does not reach the route defined as Post because it is sent as Get.
Note:
The problem is gone, I was about to upload the form with raw html to get out of the error and I realized that the error was corrected, I do not know if it was a server error, the strange thing is that other forms did not fail and when submitting the form laravel did not throw me any error.
Good day to all, I am beginner in Laravel and as you know html form by default sends POST requests and wanted to ask if it is ok if I omit POST at the beginning of form tag since I want to send POST request to server The code:
{!! Form::open(['method' => 'ToDoController#store' **I am not specifying type of request**]) !!}
<div class="form-group">
{{Form::label('text', 'Text', ['class' => 'awesome'])}}
{{Form::text('text', '', ['class'=>'form-control' ,'style'=>'width:200px'])}}
</div>
<div class="form-group">
{{Form::label('text', 'Text', ['class' => 'awesome'])}}
{{Form::text('text', '', ['class'=>'form-control' ,'style'=>'width:200px'])}}
</div>
{{Form::submit('Submit')}}
{!! Form::close() !!}
It is OK to omit an attribute if the default is what you intend to carry out. However, you should note the following.
HTML forms by default sends 'GET' requests.
Form Collective which is a package used in Laravel Framework has by default set the method attribute of HTML forms to 'POST'.
So, the reason why your form is sending a 'POST' even when you didn't set the method attribute is because you are using Form Collective else your form would have defaulted to 'GET'.
Meanwhile, from the snippet you pasted:
{!! Form::open(['method' => 'ToDoController#store' **I am not specifying type of request**]) !!}
Change that to:
{!! Form::open(['action' => 'ToDoController#store']) !!}
The method attribute is meant for specifying the kind of request...chiefly 'GET' or 'POST' while the action attribute is meant for specifying the Controller action that will handle the request.
I am using Laravel blade, I am facing problem that am not able to get the input name for dropzone area to save to the database in dropzone.js. So I need to set name for dropzone area which must be type array.
Below is my code.
{!!Form::model(null,array('url'=>'/assets/global/plugins/dropzone/upload.php','class'=> 'dropzone dropzone-file-area', 'id'=> 'my-dropzone','files'=>'true','style'=>"width: 100%;height:50px;")) !!}
<h3 class="sbold">**Drop files here or click to upload**</h3>
{!! Form::close() !!}
Remove 'id'=> 'my-dropzone' from Form::model() and put it in div inside the form:
<div id="my-dropzone"></div>
I'm struggling with Laravel 5.1 LTS's requests. Every time I upload a file, I get the file name from $request->input('input_file'), but
$request->hasFile('input_file') is false and
$request->file('input_file') is null.
Frontend
{!! \Form::input('file','input_file',null,['style'=>'display:none;']) !!}
which translates to
<input type="file" name="input_file" id="input_file" style="display:none;">
Don't forget to add enctype="multipart/form-data" to your <form> element.
If you're using Laravel Collective's Form/Html package, you can pass 'files' => true to the array:
{!! Form::open(['files' => true]); !!}
I think you are missing 'files'=>'true'
Try this,
Form::open(array('url' => '/uploadfile','files'=>'true'));
{!! Form::label('Date:') !!}
{!! Form::input('date','start',null,['class'=> 'form-control'])!!}