There's a MaxFiles configuration option for dropzone. http://www.dropzonejs.com/#configuration-options
Dropzone.options.myAwesomeDropzone = {
paramName: "file", // The name that will be used to transfer the file
maxFiles: 6
};
In the Project Flyer, say I would like to only allow a maximum of 6 photos to be associated with any flyer.
What would be the best way to implement this when a user attempts to upload new photos via the dropzone utility?
I don't believe this fits into the criteria of being an exception - as it is hardly an exceptional set of circumstances that a user could try to upload more than 6 photos.
Within the AddPhotoToFlyer class I've added a simple call to check that the count(*) of photos is less than 6 for the Flyer instance.
protected function makePhoto()
{
// make sure max images not exceed
if ($this->countPhotos() <6) {
return new Photo(['name' => $this->makeFileName()]);
}
else {
//todo Return a nice message to the view
abort(403,'Max photos of 6 reached ');
}
}
protected function countPhotos()
{
return $this->flyer->photos()->count();
}
With the above, we just get a 403 response.
How can a flash message be passed back to the view to visually alert the user that a max of 6 images has been reached? A user isn't going to want to enable Chrome developer tools to view the response message.
Please or to participate in this conversation.