2016-05-14 68 views
0

我想上傳<img>標籤src在我的spring mvc中。我已經嘗試使用輸入文件方法上傳img。但有可能上傳一個img src到彈簧控制器?在不使用文件輸入的情況下上傳圖片標籤源

<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

您需要將您的數據插入form才能將submit數據存入數據庫或其他用途。

由於<img src="demo.png" />只是一個靜態的html的代碼,表格無法從中得到data

你可以做的是src<input type="file" name="file" />

相關問題