I have a page where file upload inputs will be customizable via a backend, so my call to uploadify is on a class, like this:
$('.uploadify_upload').uploadify({
'uploader' : '../js/uploadify/uploadify.swf',
'script' : '../js/uploadify/uploadify.php',
'cancelImg' : '../js/uploadify/cancel.png',
'checkScript' : '../js/uploadify/check.php',
'folder' : '../img/uploads/temp/<?= $upload_temp_folder ?>/',
'auto' : true,
'multi' : false,
'buttonText': 'Upload image',
onComplete: function (event, queueID, fileObj, response, data) {
$('#file_name').text(fileObj.name);
}
});
The html looks like:
<div class="image_preview" id="preview_<?= $field['field_name_in_channel_data'] ?>">
<input type="file" class="uploadify_upload" id="upload_<?= $field['field_name_in_channel_data'] ?>" name="upload_<?= $field['field_name_in_channel_data'] ?>"/>
</div>
I want to be able to obtain the div id (preview__..) or input id(upload_...) inside my uploadify function. This way, I can let the backend know for which field the upload was, in order to appropriately write in the DB later. I tried
'onSelect' : function(event,data) {
var div_id = $(this).parent().attr('id');
alert(div_id);
},
among others but without success.. What can I do?
This is the answer:
From Uploadify: Passing a form's ID as a parameter with scriptData