请帮助我解决这个问题我不知道为什么当我附加.pdf它有问题,当我附加图像时它可以附加文件唯一发生的事情就是当我附加.pdf它是不附加。提前谢谢。
//Trim the input text
function Trim(input) {
var lre = /^\s*/;
var rre = /\s*$/;
input = input.replace(lre, "");
input = input.replace(rre, "");
return input;
}
// filter the files before Uploading for text file only
function CheckForTestFile() {
var file = document.getElementById('<%=fudata.ClientID%>');
var fileName = file.value;
//Checking for file browsed or not
if (Trim(fileName) == '') {
alert("Please select a file to upload!!!");
file.focus();
return false;
}
//Setting the extension array for diff. type of text files
//var extArray = new Array("doc", "docx", "pdf", "jpg", "png");
var extArray = new Array("png", "jpg", "pdf");
var Extension = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
//matching extension with our given extensions.
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == Extension) {
return true;
}
}
alert("Please only upload files that end in types: "
+ (extArray.join("")) + "\nPlease select a new "
+ "file to upload and submit again.");
file.focus();
return false;
}
HTML
<asp:Panel ID="PanelAttacheFile" runat="server" EnableTheming="True">
<asp:DataList ID="DataList1" runat="server" DataKeyField="tafID" RepeatColumns="5">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" ImageUrl='<%# "~/TicketAttachmentImage.ashx?AsThumbnail=true&imageid=" & CStr(Eval("tafID"))%>'
runat="server" />
<br />
<asp:Label ID="FileNameLabel" runat="server" Text='<%# Eval("FileName") %>' />
<br />
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="remove">Remove</asp:LinkButton>
<br />
<asp:HyperLink ID="downloadimg" runat="server" Text="View" NavigateUrl='<%#"~/TicketAttachmentImage.ashx?AsThumbnail=false&imageid=" & CStr(Eval("tafID")) & "&filename=" & Eval("FileName")%>'
Target="_blank" />
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<table style="width: 100%">
<tr>
<td class="captionwidth "></td>
<td class="captionwidth ">
<asp:Button ID="bttnPost" runat="server" Text="Post" ValidationGroup="group1" Width="87px" CssClass="ButtonStyle" />
</td>
<td class="fileupwidth">
<asp:FileUpload ID="fuData" runat="server" Width="328px" />
</td>
<td>
<asp:Button ID="bttnAttached" runat="server" Text="Attach" Width="76px" OnClientClick="return CheckForTestFile();" CssClass="ButtonStyle" />
</td>
</tr>
</table>