我在我的项目中使用 dropzone 。它在 Firefox 和 google chrome 中运行良好。 但是当我在 safari 和 ie 8 中测试它时,它不起作用。 当我选择图像时,它会停止在 ajax 文件上,并在地址栏中显示 ajajx 文件 url。
网址是这样的http://localhost/wall/modules/gallery/ajax.php?page=gallery
我的拖放区看起来像这样,请查看图片网址
http://awesomescreenshot.com/08d2pwvj2f
我的 jquery 代码是:
//function for messages onclick upload image button
$(document).ready(function(){
//e.preventDefault();
//var new_album=$(".album_name").val();
//var selected_album=$(".selected_album").val();
Dropzone.autoDiscover = false;
if($("div#dropzonefrm .msg_up_img").hasClass('dropzone'))
{
$("div#dropzonefrm .msg_up_img").remove();
}
else
{
$("div#dropzonefrm").html("<div class='msg_up_img'></div>");
$("div.msg_up_img").addClass('dropzone');
$("div.msg_up_img").dropzone({ url: "modules/gallery/ajax.php?page=gallery" ,acceptedFiles : ".jpeg,.jpg,.png,.gif,.JPEG,.JPG,.PNG,.GIF", });
var sendingHandler = function(file, xhr, formData) {
//formData.append('album_name', $(".album_name").val());
//formData.append('selected_album', $(".selected_album").val());
};
$('div.msg_up_img').each(function() {
Dropzone.forElement(this).on('sending', sendingHandler);
Dropzone.forElement(this).on("success", function(file,response) {
alert(response); //The response
$(".last_insert_id").val(response);
});
});
}
});
我的html是:
<div class="gallery_cnt">
<a href="#" class="new_album_txt">Create New Album-:</a><input type="text" style="display:none;" class="album_name" value="" placeholder="please enter Album Name"/>
OR <a href="#" class="album_slct_box" style="display:none;">Click here select album</a>
<?php stream_img_upload($con,$page); ?>
<button type="button" class="btn btn-primary btn-lg add_img_to_gall">Add image to album</button>
</div>
这是我在 html 中调用的 php 函数
function stream_img_upload($con,$page)
{
$user_id=$_SESSION['id'];
$album_name_query=mysqli_query($con,"select album_name,id from album where login_id='$user_id'");
echo '<span class="gallery_name_display" ><select class="selected_album" name="album_slct">
<option value="">Select Gallery</option>';
while($album_name_query_result=mysqli_fetch_assoc($album_name_query))
{
$album_name=$album_name_query_result['album_name'];
$album_id=$album_name_query_result['id'];
echo '
<option value="'.$album_id.'">'.$album_name.'</option>';
}
echo '</select></span>';
echo '<div>
<div style="float:left;margin-left:10px;">Title<input type="text" class="img_ttl"/></div>';
echo '<div>Description<input type="text" class="img_desc"/></div>
</div>';
echo '<div class="gallary_upld_cnt">';
echo '<span class="up_resp"><input type="hidden" class="up_img_resp" value=""></input><input type="hidden" class="cmt_img_resp" value="" mid=""></input></span>';
echo '<div id="dropzonefrm" ></div>';
echo '</div>';
}
现在我已经显示了所有代码,所以请帮助我..
你们是摇滚且天才的 friend 。
请帮助我解决这个问题,我花了很多时间但没有结果。
提前致谢,如果有不清楚的地方请询问我。
最佳答案
Dropzone 不支持版本 10 之前的 IE 或版本 6 之前的 Safari。请参阅 http://www.dropzonejs.com/#browser-support其中说:
As a side note: I have received various «complaints» about not supporting earlier versions of Internet Explorer – some even called me an IE hater. Although I don’t really object to that, the reason I do not support earlier versions of IE is very simple: IE up until version 10 does not provide the required APIs to implement only a fraction of what Dropzone aspires to do. If I were an IE hater, I wouldn’t implement IE10 either. But IE10 actually supports the APIs Dropzone requires, so it’s supported. It’s as simple as that. (The same goes for earlier versions of Firefox, Opera and Safari but those browsers have a good conversion rate and nobody uses Firefox 3.5 anymore. Why some people still use IE8 is beyond me.)
关于php - Dropzone 在 Safari 和 IE 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23333670/