-1
我有這個母版頁和網頁形式與主頁我遇到的問題是代碼將不會運行或保存到我想要它的文件夾,所以如何更改代碼在vb中? 基本上我有有一個輸入,讓我上傳文件或圖像一個javascript,但問題,它看起來像總跳過內部麻煩保存圖像上傳在php
<script type = "text/javascript">
var counter = 0;
function AddFileUpload() {
var div = document.createElement('DIV');
div.innerHTML = '<input id="file' + counter + '" name = "file' + counter + '" type="file" /><input id="Button' + counter + '" type="button" value="Remove" onclick = "RemoveFileUpload(this)" />';
document.getElementById("FileUploadContainer").appendChild(div);
counter++;
}
function RemoveFileUpload(div) {
document.getElementById("FileUploadContainer").removeChild(div.parentNode);
}
$(document).ready(function() {
AddFileUpload();
});
</script>
<span style ="font-family:Arial">Click to add files</span>
<br /><br />
<div id = "FileUploadContainer">
<!--FileUpload Controls will be added here -->
</div>
<br />
<input id="ButtonAdd" type="button" value="add" onclick = "AddFileUpload()" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" />
<asp:Label ID="lbl2" runat="server" ForeColor="Red"></asp:Label>
<br />
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
For i As Integer = 0 To Request.Files.Count - 1
Dim PostedFile As HttpPostedFile = Request.Files(i)
If PostedFile.ContentLength > 0 Then
Dim FileName As String = System.IO.Path.GetFileName(PostedFile.FileName)
PostedFile.SaveAs(Server.MapPath("Files\img\") + FileName)
Else
lbl2.Text = "No images have been selected to upload "
End If
Next
End Sub
沒有什麼我的意思是我無法保存圖像 – actKing 2012-02-03 08:14:11
什麼是你得到的錯誤或根本沒有錯誤信息?... – RohitWagh 2012-02-03 08:22:37
有沒有錯誤,我更新我的代碼,基本上我有一個JavaScript的輸入,允許我上傳一個文件或圖像,但問題,它似乎總共跳過 – actKing 2012-02-03 08:27:04