0

Currentl i have a uploadify multifile upload for users to upload image, for every image they select i would want to allow them to enter some description and than i will store the description together with the image URL into my database , now i have generated the textbox for every image selected to upload but how do i pass the value to my handler so to store it in my db? below are my codes

Uploadify JQuery:

$(document).ready(function () {
            $("#<%=FileUpload1.ClientID %>").uploadify({
                'swf': '../../Uploadify/uploadify.swf',
                'uploader': 'Handler.ashx',
                'auto': false,
                'multi': true,
                'buttonText': 'Select Photos',
                'fileDesc': 'Image Files',
                'fileTypeExts': '*.gif; *.jpg; *.png',
                'queueSizeLimit': 12,
                'onQueueComplete': function () {
                    window.location.reload();
                },
                'onSelect': function (file) {
                    $('#textboxtables').append("<tr><td style='height:50px; vertical-align:middle'><input type='text' id='" + file.name + "'/></td></tr>");
                }

            });
        });

So for every file / image i select i will generate a tablerow with a texbox with the filename as the ID, but now how do i get the value of the textbox and pass it to my handler?

4

2 に答える 2

2

私は解決策を持っています:

$(function() {

  $("#<%=FileUpload1.ClientID %>").uploadify(
    {
     'swf': '../js/uploadify/uploadify.swf',
     'uploader': '../uploader.ashx',
     'auto': false,
     'method': 'post',
     'multi': true,
     'buttonText': 'Select File(s)',
     'folder': '../images',
     'fileDesc': 'Image Files',
     'fileExt': '*.jpg;*.jpeg;*.gif;*.png',

     'onUploadStart': function (event, data) { //this is where you will send the form //data, but remember to get if from post in the .ashx file, by contex.Request["gallaryId"]


         $("#<%=FileUpload1.ClientID %>").uploadify('settings','formData',

         { 'gallaryId': $("#hiddenGallaryId").val() }  //note hiddenGallaryId would //have the gallaryId which im sending through post , make sure it is rendered in your page( //i.e.not concealed by a multiview control e.t.c)
         );
     }          

   });
 });

HTML:

<asp:FileUpload ID="FileUpload1" runat="server" /> 
<input id="hiddenGallaryId" type="text" class="hiddenFields"/>

<a href="javascript: $('#<%=FileUpload1.ClientID %>').uploadify('upload','*')">Click To Upload Files</a>
于 2012-10-22T16:10:10.050 に答える
0

Jquery uploadify の「formData」のプロパティを介してハンドラに値を渡すことができます

$("#<%=FileUpload1.ClientID %>").uploadify({
    // your existing stuff
    'formData' : { 'query' : $(YourTextBoxId).val() }
});

この "query" 変数は、テキスト ボックスの値をクエリ文字列パラメーターに渡します。Request["query"]式を使用して、ハンドラーでこの値を取得できます。

于 2012-08-11T16:15:43.637 に答える