我有一个页面,可以通过后端自定义文件上传输入,所以我对 uploadify 的调用是在一个类上,如下所示:
$('.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);
}
});
html 看起来像:
<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>
我希望能够在我的 uploadify 函数中获取 div id ( preview__..
) 或输入 id( )。upload_...
这样,我可以让后端知道上传的字段是哪个字段,以便以后适当地写入数据库。我试过
'onSelect' : function(event,data) {
var div_id = $(this).parent().attr('id');
alert(div_id);
},
除其他外,但没有成功..我该怎么办?