Sopamo / laravel-filepond

Laravel backend module for filepond uploads
MIT License
203 stars 56 forks source link

Multiple input #1

Closed xerod closed 5 years ago

xerod commented 5 years ago

if i have multiple input, how could i differentiate between the first one and the other? the request (for $serverId) only get the value from the last input.

edit: this two filepond input is for different purpose, that's why i don't use allowMultiple here.

xerod commented 5 years ago
    public function upload(Request $request)
    {
        foreach ($request->file('file') as $file) {
            $filePath = tempnam(config('filepond.temporary_files_path'), "laravel-filepond");
            $filePathParts = pathinfo($filePath);

            if (!$file->move($filePathParts['dirname'], $filePathParts['basename'])) {
                return Response::make('Could not save file', 500);
            }
            return Response::make($this->filepond->getServerIdFromPath($filePath), 200);
        }
    }

i've figured it out and modified your FilepondController, so it can handle multiple input (and i think works with allowMultiple too).