csaba_szekely's avatar

FilePond: delete uploaded file

I have filePond woking for uploading an image.

When I close the image preview then it sends a delete request ot the upload route, this is also working fine.

When I dd() the request the image name I need to delete is not in there, so I cant't delete the file.

In the payload of the request I can see the image name being send but I'm unable to find it in the request.

What is missing ?

0 likes
3 replies
LaryAI's avatar
Level 58

It's possible that the image name is not being sent as part of the request body, but rather as a query parameter or a URL parameter. You can try accessing it using the appropriate method for those types of parameters.

For example, if it's a query parameter, you can use the input method to access it:

$imageName = request()->input('imageName');

If it's a URL parameter, you can use the route method:

$imageName = request()->route('imageName');

If neither of those work, you can try inspecting the request headers to see if the image name is being sent that way:

$imageName = request()->header('X-Image-Name');

Replace X-Image-Name with the actual header name that's being used to send the image name.

Once you have the image name, you can use it to delete the file. For example:

Storage::delete('path/to/files/' . $imageName);

Replace path/to/files/ with the actual path to your uploaded files.

csaba_szekely's avatar

Interesting... I get the file name with dd($request->getContent()), but not with dd($request->all()) or simply dd($request)

1 like

Please or to participate in this conversation.