Adithya1997's avatar

Removing files from request before passing to controller

I am doing image upload in my Laravel application where after selecting some images I want to remove some selected images , I have done that but when submitting ,the request still has all the images selected at the beginning.

0 likes
5 replies
mlazuardy's avatar

Try this

 if ($request->hasFile('image')) {
            unlink($image);
            $request->file('image')->store('public/blogs/' . $request->user()->id);
            $blog->image = $request->file('image')->hashName('blogs/' . $request->user()->id.'/');
        }

this is just example in update method, so configure it with your own Controller

Adithya1997's avatar

I want to unlink it from the client side itself ie. before reaching the the controller

Snapey's avatar

Cannot tell what you are trying to do

Adithya1997's avatar

ok I will tell clearly... I am doing an image uploading functionality in my laravel application. then user can select as many images as he need.later before submitting the form if the user wishes to remove one or two images from his selection,he can do it..but the problem is when sumbitting the form after removing some images...the form still has all the images in its request parameter when seen from the controller side..

What i need i need to unlink the files deselected by the user from the client side itself and then sent to server side...so as to reduce the load

Snapey's avatar

So this is a javascript issue then?

Please or to participate in this conversation.