Uncaught TypeError: $(...).find(...).not(...).size is not a function

1.6k views Asked by At

I am using uploadify to upload file in laravel with progressbar implementation. but when I am uploading file, I am getting this error in console.

Uncaught TypeError: $(...).find(...).not(...).size is not a function
    at HTMLInputElement.<anonymous> (jquery.uploadifive.js:814)
    at Function.each (jquery-3.5.1.min.js:2)
    at S.fn.init.each (jquery-3.5.1.min.js:2)
    at S.fn.init.upload (jquery.uploadifive.js:770)
    at S.fn.init.$.fn.uploadifive (jquery.uploadifive.js:872)
    at <anonymous>:1:19

I am using laravel and the blade view is
uploadForm.blade.php

@extends('layouts.artist')
@section('content')
<div id="queue"></div>
    <input id="file_upload" name="file_upload" type="file" multiple="true">
    <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
@endsection

@section('script')
<script type="text/javascript">
        $(function() {
            $('#file_upload').uploadifive({
                'auto'             : false,
                'checkScript'      : '',
                'fileType'         : 'image/png',
                'formData'         : {
                                       '_token'     : "{{csrf_token()}}"
                                     },
                'queueID'          : 'queue',
                'uploadScript'     : "{{route('track.upload')}}",
                'onUploadComplete' : function(file, data) { console.log(data); }
            });
        });
    </script>
@endsection

and my controller is this
TrackController.php

function upload(Request $request) {
    $title = rand(1000000, 9999999);
    $request->file_upload->storeAs('public/uploads', $title.'.png');
    $response = ['status' => 'ok', 'message' => $title.' successfully uploaded.'];
    return response()->json($response);
}

Any help is highly appreciated.

1

There are 1 answers

2
Rory McCrossan On

The size() method was deprecated in jQuery 1.8 and removed entirely in 3.0 and higher. You should use length instead.

That call appears to be coming from the uploadifive() library you're using. As such I would assume that library is very outdated. I'd suggest finding an alternative.