我使用jquery.form.js上傳圖像,它可以在除IE以外的所有瀏覽器中工作。 版本:3.32.0-2013.04.03jquery.form.js圖像上傳不工作在IE
我得到SCRIPT5:訪問被拒絕。 jquery.form.js,line 531 character 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();
}