Sopamo / laravel-filepond

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

No such file or directory #57

Closed vgavrilovikj closed 2 years ago

vgavrilovikj commented 2 years ago

I am using your library to handle filepond image upload, however when I upload the image I receive the following error: image

This is the function for uploading the image

public function imageUpload(Request $request, Filepond $filepond, $folderName)
    {
        $count = UtilController::countOccurrencesInString($filepond->getPathFromServerId($request->input('image_upload')), '/');
        if ($count > 1) {
            $image = UtilController::replaceFirstString('/', '\\', $filepond->getPathFromServerId($request->input('image_upload')), $count-1);
        } else {
            $image = $filepond->getPathFromServerId($request->input('image_upload'));
        }

        $parts = explode("/", $image);
        $pathArr = explode('.', $image);
        $imageExt = '';
        if (is_array($pathArr)) {
            $imageExt = end($pathArr);
        }

        $name = explode(".", $parts[1]);
        $fileName = $name[0] .'-'.rand().'.'.$imageExt;
        $finalLocation = $folderName . '/' .$fileName;

        try {
            Storage::disk('s3')->put($finalLocation, file_get_contents($image));
        } catch(Exception $e) {
            return response()->json(array('message' => $e), 500);
        }

        return $fileName;
    }

Could you please help me with it? Thanks!

Sopamo commented 2 years ago

I'm guessing this is a specific issue with your setup. If this is still an issue, feel free to open a new issue with a minimal reproduction, then I can have a look.