JackD's avatar
Level 6

Limit photo upload for item dropzone

Hi i have this in my controller to control the maximum number of allowed image to upload for an item, it is working if it is in a batch upload but not if example i have already 9 images that is already uploaded and i tried to upload again more than 10 now since it automatically uploads the images dropped into the box. How can i make it work to only accept not more than 10 images even though there's already 9 images stored for that item?

if( $photo->countAll() <= 10) {
            $photo = Input::all();
            $response = $this->image->upload($photo);
            return $response;
}
return redirect()->back();
0 likes
1 reply
tomopongrac's avatar

You need to check if images exist ... something like this in pseudocode

$number_of_stored_images = $this->method_for_check_number_of_images();

if( $photo->countAll() <= 10 - $number_of_stored_images) {
            $photo = Input::all();
            $response = $this->image->upload($photo);
            return $response;
}
return redirect()->back();

1 like

Please or to participate in this conversation.