我正在使用 jquery.form.js 上传图片,它可以在除 IE 之外的所有浏览器中使用。版本:3.32.0-2013.04.03
我收到 SCRIPT5:访问被拒绝。jquery.form.js,第 531 行字符 21
我还使用自定义上传按钮来提交文件,这可能是问题的一部分,但我不确定。
我什至尝试更改为另一个插件但没有成功,但我真的很想让这个插件工作,因为我在网站的其他页面中使用该插件。
HTML:
<input type="button" id="uploadButton" name="upload" value="" class="uploadButton"/>
<br><div id="uploadLimit">Images cannot exceed 5mb.</div>
<form id="uploadForm" action="inc/ajax-ftlib.php" method="post" enctype="multipart/form-data" style="position:absolute;left:-99999px;">
<input id="uploadFile" type="file" name="image" />
<input type="submit" value="Submit" id="submit-btn" />
<input type="hidden" name="cmd" value="uploadImage">
<input type="hidden" name="postId" value="0">
</form>
JS:
// hook up custom upload button
$('#uploadButton').bind('click', function() {
$('#uploadFile').trigger('click');
});
$('#uploadFile').bind('change', function() {
$('#submit-btn').trigger('click');
});
var options = {iframe: true, dataType: 'json', beforeSubmit: imageUploadRequest, success: imageUploadResponse, uploadProgress: imageUploadProgress, submit: imageUploadSubmit};
$form = $('#uploadForm');
$form.ajaxForm(options);
function imageUploadResponse(response){
var fileName = response;
//alert(fileName);
// add the image to the thumbnail ui here / remove any loader image
var path = "img/post/" + postId + "/" + fileName;
var $newdiv = $('<div class="item" name=' + fileName + '><input type="button" class="thumbClose"/></div>');
$newdiv.css('background-image', 'url(' + path + ')');
$("#list").append($newdiv);
$('#uploadButton').show();
$('#uploadLimit').show();
}