Plupload在ipad中不起作用

时间:2015-10-16 09:45:14

标签: javascript jquery file-upload plupload

我正在使用Plupload在我的网站上传图片。它在所有桌面浏览器上都像魅力,但不在i-pad中。当我点击上传按钮时,它会刷新页面。我搜索过,没有找到任何解决方法。最后,我在这里问我的问题。我正在使用pl上传Core Api。

这是我的代码:

var uploader = new plupload.Uploader({
        runtimes : 'html5,flash,silverlight,html4',
        browse_button : 'local_file_upload', // you can pass an id...
        container: document.getElementById('container'), // ... or DOM Element itself
        url : "<?php echo WEBSITE_URL . '/includes/upload.php';?>",
        unique_names : true,
        multi_selection: false,
        max_file_count: 1,
        flash_swf_url : pl_upload_url+'Moxie.swf',
        silverlight_xap_url : pl_upload_url+'/Moxie.xap',
        filters : {
            max_file_size : '10mb',
            mime_types: [
                {title : "Image files", extensions : "jpg,gif,png,jpeg"},
            ]
        },

        init: {
            PostInit: function() {
                document.getElementById('filelist').innerHTML = '';
     
                document.getElementById('upload_images').onclick = function() {
                    uploader.start();
                    jQuery("#upload_images").css("display","none");
                    return false;
                };
            },
            FileUploaded: function (up, file) {
                if(image_path != "")
                {
                    jQuery("#filelist").css("display","none");
                    var ajaxURL = "../includes/ajax.php";
                    jQuery.post(ajaxURL,"image_path="+image_path+"&ajax=true&action=uploadImage",function(data)
                    {
                        jQuery("#preview_image").html("<img src='<?php echo WEBSITE_URL.'/uploads/users/'.$user_id.'/thumbnail/'?>"+file.target_name+"' style='width:100%'/>");
                    });
                }
                else
                {
                    alert("<?php echo _("Kinldy select image to upload");?>");
                }
            },
            FilesAdded: function(up, files) {
                if (uploader.files.length == 2) {
                    uploader.removeFile(uploader.files[0]);
                }
                plupload.each(files, function(file) {
                    jQuery("#filelist").css("display","block");
                    var img_type = file.name;
                    var type = img_type.split(".");
                    image_path = file.id+"."+type[1];
                    document.getElementById('filelist').innerHTML = '<div id="' + file.id + '" >' + img_type + ' (' + plupload.formatSize(file.size) + ') <b image_path="'+file.id+"."+type[1]+'" style="color:#fff;" onclick="removeImage(this);">x</b></div>';
                    jQuery("#upload_images").css("display","block");
                });
            },
     
            UploadProgress: function(up, file) {
                jQuery("#"+file.id).find("b").html('<span>' + file.percent + "%</span>");
            },
     
            Error: function(up, err) {
                document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
            }
        }
    });

    uploader.init();

等待回复。感谢

1 个答案:

答案 0 :(得分:0)

我在ipad上遇到类似的问题。 我复制了你的代码,它确实刷新了页面。

我尝试删除“PostInit”代码并停止刷新页面。