views:

18

answers:

1

I'm using the plugin from here: http://www.uploadify.com/

I'm trying to update/add scriptData but it isn't working. The value always remains the same, what am I doing wrong!? :(

Here is the relevant code from my header..

<script type="text/javascript">
$(document).ready(function() {
    $('#sampleFile').uploadify({
        'uploader': 'include/uploadify/uploadify.swf',
        'script': 'upload_test.php',
        'scriptData': {'full_name': 'JohnDoe'},
        'fileDataName': 'sampleFile',
        'folder': '/work/avais/bizlists/lists',
        'cancelImg': 'include/uploadify/cancel.png',
        'onAllComplete' : function(){
            $('#sampleFile').uploadifySettings('scriptData', { 'full_name': $('#full_name').val() });
        }
    });
});

</script>

I have also tried this..

<script type="text/javascript">
$(document).ready(function() {
    $('#sampleFile').uploadify({
        'uploader': 'include/uploadify/uploadify.swf',
        'script': 'upload_test.php',
        'scriptData': {'full_name': 'JohnDoe'},
        'fileDataName': 'sampleFile',
        'folder': '/work/avais/bizlists/lists',
        'cancelImg': 'include/uploadify/cancel.png',
        'onAllComplete' : function(){
            $('#sampleFile').uploadifySettings('scriptData', document.getElementById('full_name').value);
        }
    });
});

</script>

Here is my HTML code..

<div id="upload_wrapper">
    <input type="text" id="full_name" name="full_name" /><br />
    <input id="sampleFile" name="sampleFile" type="file" />
    <input type="button" name="upload" value="Upload" onclick="javascript:$('#sampleFile').uploadifyUpload();" />
</div>

I always get 'JohnDoe' returned by the 'full_name' POST var. :(

Thanks for any help!

A: 

Well I ended up using something like the below.... while it doesn't trigger on complete, it's actually better as it does it before it starts the upload.

The header is as so..

$(document).ready(function() {
    $('#sampleFile').uploadify({
        'uploader': 'include/uploadify/uploadify.swf',
        'script': 'add_list.php',
        'scriptData': {'mode': '', 'page_title': ''},
        'fileDataName': 'sampleFile',
        'folder': '/work/avais/bizlists/lists',
        'cancelImg': 'include/uploadify/cancel.png',
        'queueID': 'sampleQueue'
    });
    $("#add_list").submit(function(){
        var $upload = $("#sampleFile");
        $upload.uploadifySettings('scriptData', { 'mode': 'error_check' });
        $upload.uploadifySettings('scriptData', { 'page_title': $('#page_title').val() });
        /* Error Check */
        var error_check = checkSubmission();
        if (error_check === false) {
            $upload.uploadifyUpload(); // Triggers the upload to start.
        }
    });
});

..and the relevant HTML code is something like..

    <form name="add_list" id="add_list" method="post" enctype="multipart/form-data">
        <input type="hidden" name="mode" value="" />
        <input type="text" name="page_title" id="page_title" />
        <input id="sampleFile" name="sampleFile" type="file" />
        <div id="sampleQueue"></div>
        <input type="button" name="upload" value="Add List" onclick="javascript:$('#sampleFile').submit();" />
    </form>

I hope this helps someone else out! :)

Brett