I’m developing a simple web app and I just want to allow the user to upload some pictures.
- should I just store the picture url on my database table or should I upload the whole picture?
- how can I validate the size of the picture being uploaded?
- how can I upload the picture from my controller?
thank you all!
I would NOT store the image data in the database. I would create a Behavior that will upload the image to the image directory and store a reference to that image. The behavior can then handle size, mime type, etc. Then add a file upload form to the controller and when the data goes to the model to be saved, it will automatically upload the image and put it where it goes.
If you do not want to build your own, here is a very popular behavior that someone has built.
https://github.com/jrbasso/MeioUpload