0

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.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
boycod3
  • 5,033
  • 11
  • 58
  • 87

1 Answers1

0

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" />

Rubioli
  • 685
  • 6
  • 34