Sopamo / laravel-filepond

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

All temp files being stored outside "/public" causing for the app to not find the file and not being able to move it. #48

Closed dlogvin closed 3 years ago

dlogvin commented 3 years ago

Even after changing the configuration file, nothing really happens, everything stays the same - the file is not found.

I'm using the following code:

        $filepond = app(\Sopamo\LaravelFilepond\Filepond::class);
        $path = $filepond->getPathFromServerId($request->input('file'));

        $pathArr = explode('.', $path);

        if(is_array($pathArr)){
            $fileExt = end($pathArr);
        }

        $fileName = uniqid() . '-' . now()->timestamp . '_file.' . $fileExt;
        $finalLocation = public_path('/files/' . $fileName);
        $path = \File::move($path, $finalLocation);

Although, there is an issue: everything is being stored under /storage/filepond and not inside /storage/public/filepond.

I tried changing in the configuration the following:

'temporary_files_path' => env('FILEPOND_TEMP_PATH', 'public/tmp/files'), still, nothing goes inside, not even the folders are created. Inside Filepond.php I changed the following:

->path(config('filepond.temporary_files_path', 'public/tmp/files'));

Still, nothing, same error as always: File Not Found.

Sopamo commented 3 years ago

This is actually expected behaviour. Filepond stores the files temporarily in an internal folder and you are going to move the file to it's final location once the request with the filepond id is submitted to your controller.

dlogvin commented 3 years ago

The issue is that I am getting a "file not found" when trying to rename or as written move();

Sopamo commented 3 years ago

Not sure what your issue is here, but I suspect it's something outside of laravel-filepond. It should be no problem moving your image from storage/filepond to the location you want it to be. I would guess that maybe your target directory is missing.