这是我的代码,这是一个工作示例:
<script type="text/javascript">
var uploadify_sel = $('#uploadify');
function submitUploadify(){
var title = $('#form_name').val();
var main = $('#main1').is(':checked') ? 1 : 0;
uploadify_sel.uploadifySettings(
'scriptData', {
cookieID: '0daf9d4f8a44fcdc9c2aabc46c831203',
type: 'investments',
investment_id: '31',
title: title,
main: main
}
);
uploadify_sel.uploadifyUpload();
}
var error = null;
$(document).ready(function() {
uploadify_sel.uploadify({
uploader : 'http://localhost:8080/project/assets/flash/admin/uploadify.swf',
script : 'http://localhost:8080/project/ldmadmin/investments_gallery_ajax',
cancelImg : 'http://localhost:8080/project/assets/gfx/admin/cancel.png',
wmode : 'transparent',
method : 'post',
multi : true,
removeCompleted : false,
folder : 'uploads',
auto : false,
fileDataName: 'uploadify',
fileDesc : 'Images (.jpg, .jpeg, .png, .gif)',
fileExt : '*.jpg;*.jpeg;*.png;*.gif',
buttonText: 'Choose Image File',
scriptData : {},
onError : function(a, b, c, d){
},
onComplete : function(event, ID, fileObj, response, data){
},
onAllComplete : function(event, ID, fileObj, response, data){
if(error == null){
window.location = window.location;
}
}
});
});
</script>
提交按钮调用函数 submitUploadify() 为:
<button name="btn" class="btn" onclick="submitUploadify(); return false;">Submit form</button>
只需从中提取代码片段即可使其正常工作。这是使用 Uploadify v2.1.4 完成的