开发者

How to send extra field data to the backend using Uploadify 3.0?

开发者 https://www.devze.com 2023-02-11 23:51 出处:网络
Has anyone used Uploadify version 3.0 beta? I am having difficulty to implement it. There is no documentation available at the moment. If someone has used the script please let me know how to send ext

Has anyone used Uploadify version 3.0 beta? I am having difficulty to implement it. There is no documentation available at the moment. If someone has used the script please let me know how to send extra fields data to the backend php file. Here's what I'm tryin开发者_如何转开发g (and doesnt work) :

<script type="text/javascript">
    $(document).ready(function() {  
    $("#file_upload").uploadify({
    "swf"  : "uploadify.swf",
    "uploader"    : "uploadify.php",
    "cancelImage" : "uploadify-cancel.png",
    "auto"      : true, 
    "onUploadStart" : function(){
        $("#file_upload").uploadifySettings("postData",{
                    "name": $("#name").val(),                    
                     },0);
        },

        })
    });
</script>

HTML:

<fieldset>
    <form id="upload_form" action="" method="post" enctype="multipart/form-data">
    Name:<input type="text" name="name" id="name"/>
    <input type="hidden" name="userId" id="userId" value="1" /><br />
    choose file:<input type="file" id="file_upload" name="file_upload" />
    <div id="recordHolder" style="display:none"></div>
    </form>
</fieldset>


You can try :

'onUploadStart' : function(){
$('#mugshot_upload_new').uploadifySettings(
    'postData', 
    {
        "name": $("#name").val(),
        "userId": $("#userId").val()
    }
);
},

without "0" at the end. It works well for me.


In version 3 , This worked with me

'onUploadStart' : function() {                                                      
    $("#file_upload_1").uploadify("settings", 'formData',{"user_email_input": $("#user_email_input").val()})
}, 

Thanks!


If I get your question correct, to retrieve extra fields just add them in the onUpload function; this should work (there are no other fields I see there)

"onUploadStart" : function(){
        $("#file_upload").uploadifySettings("postData",{
                    "name": $("#name").val(),
                    "userId": $("#userId").val(),
                    },0);
0

精彩评论

暂无评论...
验证码 换一张
取 消