Hello, I am writing my first online store, and I want something that could be zakruzit image of the product directly from the admin site. Tomcat server, MySQL database, I also use Spring MVC, Hibernate. Please tell me how best to implement all uploading images to the server through the admin area.
- oneThere is no specifics in your question. You can use Spring MultipartResolver for downloading, you can store it in FS or DB. You can give through Tomcat or a dedicated HTTP server (apache, nginx). Where is the download form in the admin or not, generally your own business. So what's the question? - enzo
- Well, it’s written that from the admin site, but I’m still looking for the rest, thanks for the version with Spring MultipartResolver, and I’ll store everything in the database, give everything through tomcat. - Yurii
|
1 answer
There is nothing special about uploading images to the server through the admin panel. First of all, it doesn’t matter from the admin panel you download or from any other page. Secondly, downloading an image is no different from downloading any other file.
Unfortunately, your question is too general and does not demonstrate your attempts to find the answer yourself. What did you expect to hear back? Full listing with code? Such examples are enough on the Internet.
Here is a general algorithm:
- in view, in the form, add a field with type
file - get this file in the controller (it will be available as an argument of type
MultipartFile) - validate (empty / not empty, image or not, can the user upload files, is the file too large, etc.)
- get an array of bytes (this is the file content)
- write these bytes to the database / file system / somewhere else
- Thank you very much for the well-stated answer - Yurii
|