我想使用 Uploadify jQuery 插件在 ASP.net 中上传文件。但是当用户选择一个文件并单击“上传”按钮时,我想向服务器发送一些额外的参数。我写了这段代码:
<a id="bb" href="#">Start Upload</a>
| <a href="javascript:$('#<%=fuBrandIcon.ClientID%>').fileUploadClearQueue()">Clear</a>
<table width="50%">
<tr>
<td>BrandName</td>
<td>
<input id="BrandName" type="text" />
</td>
</tr>
<tr>
<td>BrandAbbr</td>
<td>
<input id="txtBrandAbbr" type="text" />
</td>
</tr>
<tr>
<td>
Icon
</td>
<td>
<asp:FileUpload ID="fuBrandIcon" runat="server" ClientIDMode="Static" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
</td>
</tr>
</table>
<script type = "text/javascript">
$(window).load(
function () {
alert($("#BrandName").val());
$("#fuBrandIcon").fileUpload({
'uploader': '../UplodyFile/uploader.swf',
'cancelImg': '../UplodyFile/cancel.png',
'buttonText': 'Browse Files',
'script': 'PublicHandler.ashx',
'folder': 'uploads',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'multi': false,
'auto': false,
'onUploadStart' : function(file) {
alert('Starting to upload ' + file.name);
}
// "scriptData": { 'BrandName': $("#BrandName").val(), "BrandAbbr": $("#txtBrandAbbr").val(), "ActionPage": "Brand", "Action": "Add" }
});
$("#bb").click(function() {
$('#<%=fuBrandIcon.ClientID%>').fileUploadStart();
});
});
</script>
当用户单击链接时,我想将用户选择的文件以及BrandName
发送到服务器。但是此代码发送空值和值。BrandAbbr
bb
BrandName
BrandAbbr
编辑:我写了这段代码,但我得到错误 uploadifySettingsundifine
<script>
$(function () {
$("#file_upload").uploadify({
height: 30,
swf: '../img/uploadify.swf',
uploader: 'Handler.ashx',
width: 120,
auto: false
});
$('#file_upload').uploadifySettings('name', $("#Text1").val());
});
</script>
请帮我。谢谢