Why If I upload a picture Spring Boot searches in my computer?

user14977859

I am building a spring boot application in which, at a certain point, the user has to input a file (image, text or whatever he wants) and this file is eventually going to be auto-sent to me by mail. I have used this, in my HTML template, to ask for the output;

<div class="custom-file">
 <input type="file" class="custom-file-input"
                        name="[email protected]=G8Yua" id="[email protected]=G8Yua"> <label
                        class="custom-file-label" for="[email protected]=G8Yua">Select file</label>
                </div> 

As you can see I'm using bootstrap.

In my spring boot controller I'm getting that param this way;

@RequestParam(name = "[email protected]=G8Yua", required = false) File userFile

Then the mail is going to be sent regularly (I've previously tested the mail-sending worked, when I still hadn't this file input issue), hence I'm just going to show you the attaching;

HtmlEmail email = new HtmlEmail();
email.attach(userFile);
email.send();

However, when I submit, I get this IOException in the console;

java.io.IOException: "/Users/username/Eclipse-Workspace/Website/file.txt" does not exist

I've picked up a file called file.txt, and since I'm running this on a mac computer the path is /Users/{myUsername}/{Eclipse-Workspace}/{Spring-Boot-Project/{file-name}. What I want is that Spring Boot searches out of the project, not just inside of it.

Why is it doing so? Thanks for reading!

k-wasilewski

When you want Spring to look outside the project folder you want: "file:/Users/username/Eclipse-Workspace/Website/file.txt".

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Java FXML: Why is my imageView not Showing, and how can I upload an image from my computer?

Why I get an error when I try to upload a picture

Why am I not able to get my Bean definition available in my Spring context with Spring Boot?

Why is Crashplan so slow to upload my computer's files?

I can hear my computer, Why is that

Spring Boot / JPA: Why would war conversion break functionality and/or JPA searches?

External drive doesn't boot on my computer, does when I boot in my college computer lab

Why I m still getting data from my webflux spring boot even if I unsubscribe?

Why I can not upload file to my database?

Why I can't handle multipart upload in this Spring Boot application? I obtain "no matching editors or conversion strategy found"

Why isn't my computer turning on past boot screen?

Why won't my computer boot (first time)?

Why does my computer sometimes boot up faster or slower?

Can't figure out why my computer won't boot

Why is spring boot not finding my beans?

why is my form not passing information in spring boot

Why I' m Getting Below SpringIntegration Exception while running my application with spring boot

Why can I run my app VSCode but not correctly in CLI?, its a spring boot application

Spring boot -> why i dont need to catch my exceptions inside a service?

Why do searches redirect to “SuddenLink.net”, instead of my default browser search engine? Can I prevent this?

How do I change which monitor my computer uses at boot?

How to get the IP of the computer, of searches in my google account?

Why do I get a "405 - Method Not Allowed" error when trying to open a .css file in my Spring Boot/Spring Security web app?

How can i upload a video and a picture at the same time to a server using php and my sql

I want to upload some picture files to my server and record the file name in mysql database but somehow there exists a problem

How can I increase maximum file upload in Vaadin - Spring Boot

How to upload my project to github from my computer. I have a project created which is loacted on Desktop

Why should I install hardware drivers if my computer is working fine?

Why can't I reset the password for another user on my computer?

TOP Ranking

HotTag

Archive