我想在我的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标签进行上传,而无需使用文件输入标记。
答案 0 :(得分:0)
您需要将数据插入form
才能将submit
数据发送到数据库或其他用途。
由于<img src="demo.png" />
只是一个静态html
代码,因此表单无法从中获取data
。
您可以做的是传递 src
到<input type="file" name="file" />