Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Can't change 'scriptData' when using Uploadify plugin for JQuery

    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..

    Code:
    <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..

    Code:
    <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..

    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!

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    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..

    Code:
    $(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..

    Code:
        <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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •