jgravois's avatar

Cannot upload file

I have a multi-component form and in one component, I need to upload a .pdf. However, I don't want to submit everything else because the wizard is not finished.

this is in the template:

<div class="file-field" v-if="company.is_tax_exempt">
                <!--<form>-->
                    <div class="btn btn-primary btn-sm">
                        <span>Choose file</span>
                        <input type="file" name="resale_cert" @change="onFileChange">
                    </div>
                    <div class="file-path-wrapper">
                        <input class="file-path validate" type="text" placeholder="Upload Resale Certificate">
                    </div>
                <!--</form>-->
            </div>

the onFileChange method:

onFileChange(e) {
                var files = e.target.files || e.dataTransfer.files;
                if (!files.length) {
                    return;
                }
                files.company_id = this.company.id;
                let path = '/api/resale_cert';
                console.log('UPLOAD', files);
                Vue.http.post(path, files)
                    .then(function(rsp) {
                        console.log(rsp);
                    });
            }

In the Laravel Controller, I am only doing a return $request->all(); just to see what's going wrong.

When I console log BEFORE the post, I HAVE the upload! (https://dl.dropboxusercontent.com/u/44591960/Customer_Agreement1.png)

But the response returns data: Array[0] (https://dl.dropboxusercontent.com/u/44591960/Customer_Agreement2.png)

I have been trying anything I could google for the past four hours. ANY help is appreciated!!!

0 likes
0 replies

Please or to participate in this conversation.