I am trying to figure out if it is possible to insert a file into the project using code.
I have a jsp. page which has a filechooser for the user to choose a file from, and the file is then saved into a database table as a byte[]. I also save the name of the file (in form thisIsAFile.png
) into the same table.
What I want to know is if it is possible to insert the file into the project resources?
I have created a file into the project where I would like to save the file into using code.
I am aware that right clicking the project and doing an import is a way to add a file into the designated file manually, but I do not want that, instead I need a way for the file (in this case images only) to be saved into the project automatically, every time a user chooses a file to be saved into the database from the .jsp page. The path I am trying to insert the files into is gotten from a .properties file as /images/banners/{0}
Then I only need a way to get the name (which contains the actual name + . + mime type of the file) from the database into the {0} and save it in the path as the byte[] from the corresponding row of the database.
Any help is much appreciated.