2

So I'm using uploadify to upload multiple images to a folder. Along with each upload, I want to pass along a 'batch name' from a text box value.

When I hard code the batch_name (Fire) below, the database updates fine, but when I replace 'fire' with $('#batch_name').val() the value doesn't seem to pass.

javascript

<script type="text/javascript">
$(document).ready(function() {
    $("#uploadify").uploadify({
        'uploader'       : 'uploadify/uploadify.swf',
        'script'         : 'uploadify.php',
        'scriptData'     : {'session_id': '<?php echo session_id(); ?>', 'batch_name': 'Fire'},
        'cancelImg'      : 'cancel.png',
        'queueID'        : 'fileQueue',
        'auto'           : false,
        'multi'          : true
    });
});
</script>

textbox

<input type="text" name="batch_name" id="batch_name"/>

1 Answer 1

2

You are grabbing the value of batch_name at document.ready, when (I'm guessing) the field is blank – the user hasn't had time to type a batch name when the DOM is first ready! ($('#batch_name').val() is evaluated before making (and in order to make) the call to .uploadify( ... ), not when the upload is submitted.)

In order for Uploadify to pass a batch name typed in to a field, you need to change the scriptData object before the upload is submitted.

$('#uploadify').uploadifySettings('scriptData', { 'session_id': '<?php echo session_id(); ?>', 'batch_name': $('#batch_name').val() });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.