M
M
Max6662017-01-31 04:16:20
Java
Max666, 2017-01-31 04:16:20

How to upload user photos?

Good afternoon dear developers. I did not want to divert your minds from your cool mega projects to such a trifle that I will describe further. In advance, I ask the most evil developers to be patient and understanding, and help if possible, because I'm just as new as you were in your time. Believe me, I have enough fuse to bring my project to the end, but for this I will need the help of my older brothers in arms.
I started my small web project, but unfortunately I ran into a problem or a question, how is it convenient for you, to whom in short. I turned a lot of things on the internet, but I did not find the answer, maybe I did not search well. I work in Eclipse, programming in Java.
My problem:
I can't write code to upload a user's photo to a system folder on a hard server and have a link to it stored in the sql database. And I want the photo to be assigned an individual number, which will be stored in the database link. Here's a little problem. For me, of course, it is not small, well, it is for now.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2017-01-31
@zolt85

While you, my little friend, were spreading your thoughts along the tree, and trying to verbally appease the local inhabitants, you forgot the most important thing - the clear wording of the question. After all, we are on the resource of questions and answers. So, my advice to you for the future is that you don’t need to breed snot here that you are all such a newbie. This resource is for the most part created for people like you - beginners. Therefore, immediately clearly formulate the question, form the requirements and lay it out. To a clear question, as a rule, there is no less clear answer.
Essentially, you should first read how to transfer a file from a client to a server. To save something on the server in some folder, you must have access rights to this folder. If you are using Tomcat, then by default it has access to folders located in the directory specified in the $CATALINA_HOME environment variable.
There you can configure everything as it should, but I have another suggestion: If I were you,
I would store the body of the file directly in the database, in a separate table, then you don’t need to bother with the rights, you can immediately link the user record with the file record. If the relationship is one-to-one or one-to-many, then you can directly put a foreign key on the table with files in the user. If the relationship is many-to-many, then it is better to make a separate linking table. Well, something I got carried away with the same ...
Good luck, young padawan! May the force be with you!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question