全部。
(可下載的專案代碼上傳帶有標題和描述的影像(vb.net)
源自“ blueimp/jQuery-File-Upload ”)
我正在處理這個帶有一些文本欄位的影像上傳專案,以將它們的值插入資料庫。
上面的作業示例沒有資料庫。
上傳帶有標題和描述的圖片。
加載影像時,這些欄位會顯示在頁面上。
但是,它們在上傳時會復制所有影像上的值,因為我不確定處理填充欄位的串列。
在專案中,WebForm1.aspx,在模板上傳部分。
第 144-149 行
我添加了以下內容,以便在上傳影像時顯示這些欄位。在 asp classic 中,我們將向欄位 ID 添加一個數字或欄位識別符號以傳遞給我們的代碼隱藏。但是,我不確定如何在這里添加它。我可以將影像名稱添加到 id,因為它會隨著添加的每個影像而改變。但我無法讓它發揮作用。
<td>
<input type ="text" name="ImageTitle" id="ImageTitle" value="Give Image a Title" />
</td>
<td>
<input type ="text" name="ImageDesc" id="ImageDesc" value="Give Image a Description" />
</td>
在 UploaderOne.ashx.vb 第 15、16 和 20 行
15 Dim ImageTitle As String = context.Request.Form("ImageTitle")
16 Dim ImageDesc As String = context.Request.Form("ImageDesc")
20 .Name = file.FileName " - " ImageTitle " - " ImageDesc,
第 20 行,我將 ImageTitle 和 ImageDesc 添加到輸出中,以確保我從欄位中獲得一些回報。接下來,我需要使用我不確定的陣列。
我發現這個執行緒通過 Jquery File Upload 將標題欄位添加到每個單獨的檔案?
我正在查看它以及作者目前提供的鏈接。希望我能從中得到我需要的東西。
uj5u.com熱心網友回復:
更新和作業
將 WebForm1.aspx 中的代碼更新為以下內容。
主要關注點在這些線路上。
<td class="title">input type ="text" name="ImageTitle[]">
<td class="desc">input type ="text" name="ImageDesc[]">
正如所注意到的,每個都有一個類,然后將 [] 添加到名稱中。
<td class="title">
<input type ="text" name="ImageTitle[]" id="ImageTitle" value="Give Image a Title" required/>
</td>
<td class="desc">
<input type ="text" name="ImageDesc[]" id="ImageDesc" value="Give Image a Description" required/>
</td>
然后將其添加到身體的最底部。
<script type="text/javascript">
$('#fileupload').bind('fileuploadsubmit', function (e, data) {
var inputs = data.context.find(':input');
if (inputs.filter(function () {
return !this.value && $(this).prop('required');
}).first().focus().length) {
data.context.find('button').prop('disabled', false);
return false;
}
data.formData = inputs.serializeArray();
});
</script>
在 UploadOne.ashx.vb 中。
Dim ImageTitle As String = context.Request.Form("ImageTitle[]")
Dim ImageDesc As String = context.Request.Form("ImageDesc[]")
并進行了測驗,它可以作業!每個欄位代表每個上傳的影像,就像一個魅力。
EE
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/405796.html
標籤:
上一篇:理解excelCOM中參考的含義
下一篇:如何訪問資料物件中保存的物件?
