Closed rivalex closed 2 years ago
Can be please merge this PR? I am getting a error 500 on the way it is now.
Because the upload
method is returning the full path for the file, like var/www/project/storage/app/filepond/SOME_HASH/file.jpg
.
Storage can only delete file with the path relative to the app project.
This PR should merge
It will through File Class not found Exception. Modify code like below:
public function delete(Request $request)
{
try {
$filePath = $this->filepond->getPathFromServerId($request->getContent());
$path = pathinfo($filePath, PATHINFO_DIRNAME);
\File::delete($filePath);
if (count(glob($path . '/*')) === 0) {
rmdir($path);
}
return Response::make('', 200, [
'Content-Type' => 'text/plain',
]);
} catch (Throwable $e) {
return Response::make($e->getMessage(), 500, [
'Content-Type' => 'text/plain',
]);
}
}
@rivalex thanks for your contribution! We'd have to support different disks though for this to be able to be merged.
Right now it would only work with the local disk, could you change the implementation to use Laravel's Storage
feature?
Closing this in favour of https://github.com/Sopamo/laravel-filepond/pull/53
Change the delete method to correctly remove the uploaded file, eventually remove the empty folder and retrieve a comprehensive error code in case of server error.