【问题标题】:Upload image tag source without using file input不使用文件输入上传图片标签源
【发布时间】:2016-10-27 17:58:33
【问题描述】:

我想在我的spring mvc中上传<img>标签src。我已经尝试使用输入文件方法上传 img。但是是否可以将img src上传到spring控制器?

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

我已经使用文件输入标签上传了图片。

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

是否可以在不使用文件输入标签的情况下使用img标签进行上传。

【问题讨论】:

    标签: spring-mvc


    【解决方案1】:

    您需要将数据插入到form 才能将submit 数据插入数据库或其他用途。

    由于&lt;img src="demo.png" /&gt; 只是一个静态的html 代码,因此表单无法从中获取data

    你可以做的是传递src&lt;input type="file" name="file" /&gt;

    【讨论】:

      猜你喜欢
      • 2016-09-13
      • 2017-12-23
      • 2014-11-03
      • 2012-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-18
      • 2010-11-26
      相关资源
      最近更新 更多