boycod3
boycod3

Reputation: 5319

Upload image tag source without using file input

I want to upload <img> tag src in my spring mvc. I have already tried to upload img using input file method. But is it possible to upload a img src to spring controller?

<form method="POST" action="<c:url value='/upload' />"
    enctype="multipart/form-data">
    Please select a file to upload : <input type="file" name="file" />
    <input type="submit" value="upload" />
</form>

I have already uploaded the image using file input tag.

  <form method="POST" action="<c:url value='/upload' />"
        enctype="multipart/form-data">
        Please select a file to upload : <img src="demo.png"  />
        <input type="submit" value="upload" />
    </form>

Is it possible to do the upload using img tag without using file input tag.

Upvotes: 0

Views: 387

Answers (1)

Rubioli
Rubioli

Reputation: 725

You need to insert your data to form to be able to submit the data to a database or other uses.

Since <img src="demo.png" /> is just a static html code, form can´t get the data from that.

What you can do is to pass the src to <input type="file" name="file" />

Upvotes: 0

Related Questions