Sending additional field data using Uploadify

I want to send some additional (form) field data using an append. For this purpose I use scriptData. For example, the following code correctly sends the static values ​​of the name field and location.

<script type="text/javascript">
$(document).ready(function() {
    $("#fileUpload").fileUpload({
        'uploader': 'uploadify/uploader.swf',
        'cancelImg': 'uploadify/cancel.png',
        'script': 'uploadify/upload.php',
        'folder': 'files',
        'multi': false,
        'displayData': 'speed',
        'scriptData': {'name':'JohnDoe', 'location':'Australia'}

    });
});
</script>

However, since I have the name and location of the input fields, so I want to send dynamic values. To do this, Im sends the values ​​to ScriptData as follows

'scriptData' : {'name' : $('#name').val(), 'location' : $('#location').val()}

And on upload.php, I'm trying

$name = $_GET['name'];
$location = $_GET['location'];

But he does not get any meaning. Please help me with this, as I can send additional field data. Thank.

+5
source share
4 answers

val() , DOM , . . , , onSelectOnce:

<script type="text/javascript">
$(document).ready(function() {
    $("#fileUpload").fileUpload({
        'uploader': 'uploadify/uploader.swf',
        'cancelImg': 'uploadify/cancel.png',
        'script': 'uploadify/upload.php',
        'folder': 'files',
        'multi': false,
        'displayData': 'speed',
        'scriptData': {'name':'', 'location':''},
        'onSelectOnce' : function(event,data) {
            $("#fileUpload").uploadifySettings('scriptData', {'name' : $('#name').val(), 'location' : $('#location').val()});
        }
    });
});
</script>
+2

, JSON? .. $('#location').val() "\'"+$('#location').val()+"\'".

0

Here is the code to download 3.1

$(function() {
    $('#file_upload').uploadify({
        'formData'      : {'id' : ''},
        'debug': false,         
        'buttonClass' : 'g-button g-button-blue',
        'swf'           : '../uploadify/uploadify.swf',
        'uploader'      : 'ajax/my_upload_file.php',
        'onUploadStart' : function(file) {
            $('#file_upload').uploadify('settings', 'formData', {'id' : $('#id').val() });
        }
    });
});

I need to use it because I call my form data using json and then I have to update the uploaded id post parameter

0
source

You need to specify the method by which you publish your variables:

In setup uploadify:

//...
'method': 'POST',
//...
-1
source

All Articles