1

This is the first time I'm using dropzone js. I've following requirement.

My form has following fields

  1. Name
  2. Category
  3. Description
  4. Images

Here Name is input field, Category is selector, Description is Textfield and Images is multiple file upload field.

{{ csrf_field() }}
<div class="form-group">
    <label for="name" class="col-form-label">Name</label>
    <div>
    <input  type="text" name="name" class="form-control" 
            required placeholder="Enter Name of the Package"  value="@if(isset($package)) {{$package->name}} @else {{old('name')}}@endif" />
    </div>
</div>

 <div class="form-group">
    <label for="category_id" class="col-form-label">Select</label>

    <select class="form-control" name="category_id" required>
        <option value="">Select Category</option>
        @foreach($categories as $category )
            <option value="{{$category->id}}" 
                @if(isset($package)) 
                    @if($package->category_id==$category->id) 
                        selected 
                    @endif 
                @else
                    @if(old('category_id') == $category->id)
                        selected
                    @endif
                @endif

            >{{$category->name}}</option>
        @endforeach
    </select>

</div>

<div class="form-group">
    <label>Description</label>
    <textarea name="description" class="form-control" required placeholder="Type something">{{isset($package) ? $package->description:old('description')}}</textarea>
</div>
<div class="form-group">
   //here I need multiple file upload field with dropzone js
</div>

My problem is files are not attached when form is submitted as normal post request. Is there any way to make such custom form in laravel.

I've found a lot of solution with form having image upload field only but i didn't find solution for my case. If you need further information, feel free to ask. Thanks,

Sagar Gautam
  • 9,049
  • 6
  • 53
  • 84
  • Have you seen this: https://laravelcode.com/post/laravel-56-multiple-file-upload-with-dropzonejs ?? – Hiren Gohel Nov 22 '18 at 04:53
  • @HirenGohel I've already seen that, there is only file upload field in form, in my case there are three other form fields too – Sagar Gautam Nov 22 '18 at 04:56
  • Ok, please see answers of this question: https://stackoverflow.com/questions/17872417/integrating-dropzone-js-into-existing-html-form-with-other-fields/35275260 – Hiren Gohel Nov 22 '18 at 05:01
  • I think you used `enyo/dropzone` package for it right? Please see this issue answer from GitHub issues: https://github.com/enyo/dropzone/wiki/Combine-normal-form-with-Dropzone Hope it helps you! – Hiren Gohel Nov 22 '18 at 05:18
  • @HirenGohel I've already seen these two links none work for me. – Sagar Gautam Nov 22 '18 at 05:24
  • 1
    I have similar issue related this problem. Did you found the solution? – Sa'ad Abdurrazzaq Apr 14 '20 at 13:02

1 Answers1

0

You could try using the .getAcceptedFiles() or similar to get the files that are uploaded and then pass that info in an ajax post or get.

Josh
  • 1,316
  • 10
  • 26