0

I'm pretty new to javascript and jQuery. I'm using Uploadify to upload images to the server. There are multiple Uploader objects on the page. I need to pass the id of the Uploader object being used to the server. This is what I have so far:

$('input.ImageUpload').uploadify({
    ...
    'scriptData': {'id': ??????},
    ...
});

How can I make this happen? I've tried "this.id" and "$(this).attr('id')". Am I even going about this in the correct way?

2 Answers 2

2

I'm not sure if this is ideal, but this is what I ended up doing:

$('input.ImageUpload').each(function() {
  $(this).uploadify({
    ...
    scriptData({'id': $(this).attr('id')},
    ...
  });
});
Sign up to request clarification or add additional context in comments.

Comments

1

This is how I use it successfully:

$(document).ready(function() {
    $(".upload").each(function() {
        $(this).uploadify({
            'uploader'      : '/code/js/jquery.uploadify/example/scripts/uploadify.swf',
            'script'        : '/code/js/jquery.uploadify/example/scripts/uploadify.php',
            'cancelImg'     : '/code/js/jquery.uploadify/example/cancel.png',
            'folder'        : '<?=$upload_path?>' + $(this).attr('id'),
            'queueID'       : 'fileQueue',
            'auto'          : true,
            'multi'         : false,
            'scriptData'        : ({'var_name': 'this_var_value'}),
            'fileDesc'          : 'Images and PDF files only! (JPG, PNG, PDF)',
            'fileExt'               : '*.pdf;*.jpg;*.jpeg;*.png',
            'buttonText'        : 'browse' +  $(this).attr('id')
        });
    });
});



<div id="fileQueue"></div>
<input class="upload" type="file" name="ImageUpload" id="_ID_1" /><br />
<input class="upload" type="file" name="ImageUpload" id="_ID_2" /><br />
<input class="upload" type="file" name="ImageUpload" id="_ID_3" /><br />

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.