Dropzone.js 和 Laravel 得到 500(内部服务器错误)

Dropzone.js with Laravel get 500 (Internal Server Error)

我尝试使用 dropzonejs 库上传图片。我已按照有关 dropzone 的文档进行操作,但出现内部服务器错误。

html:

<form action="http://localhost/visitingcy/public/management/create-thing"
      class="dropzone"
      id="my-awesome-dropzone">
    <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
</form>

Laravelphp代码:

        if ($request->hasFile('file')) {
        $getImages = $request->input('file');
        $count = 0;
        $images = array();
        foreach ($getImages as $img) {
            $imageURL = str_slug($newThing->title) . '.' . $img->getClientOriginalExtension();
            $checkForDuplicate = DB::table('things_images')->where('url', '=', $imageURL)->get();

            while (!empty($checkForDuplicate)) {
                $imageURL = str_slug($newThing->title) . $count . '.' . $img->getClientOriginalExtension();
                $checkForDuplicate = DB::table('things_images')->where('url', '=', $imageURL)->get();
                $count++;
            }
            $images[] = ThingImage::create(['url' => $imageURL]);

            //save file to public directory
            $img->move(base_path() . '/public/img/thing/gallery/', $imageURL);
        }
        return $images;
    } else {
        dd('there isnt file');
    }

我发现了问题。我曾使用过 foreach,但 dropzone 单独上传每个文件,因此不需要。控制台的 500 错误是因为我的控制器中的另一个功能有问题。