I want use Uploadify jQuery plugin to upload files in ASP.net. But when a user selects a file and clicks the 'Upload' button I want send some additional parameters to the server. I have written this code:
<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>
I want to send the file selected by the user as well as BrandName
and BrandAbbr
to the server when the user clicks to bb
the link. But this code sends empty BrandName
and BrandAbbr
values.
Edit: i write this code but i get error uploadifySettings in undifine
<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>
Please help me. Thanks