3

我在使用 plupload 上传 jpeg 时遇到问题。它不会保留我的初始图像的方向,并且每次都将其设置为横向。

我也尝试过使用 png,在这种情况下它工作正常。

这是我的代码:

    $files = new Array();

    //return number of file authorized for selected city
    $.ajax({
        type: "GET",
        //dataType: "jsonp",
        cache: false,
        url: "/fileauthorized",
        data: {
            cityid : $cityid
        },
        success: function(data) {

            $nbfile = data; 
            $nbfileauthorized = 5 - $nbfile;

            uploader = new plupload.Uploader({
                runtimes : 'html5,flash',
                browse_button : 'pickfiles',
                container : 'container',
                max_file_size : '10mb',
                chunk_size : '1mb',
                url : '/addphototemptorep',
                flash_swf_url : '/plupload/js/plupload.flash.swf',
                unique_names : true,
                filters : [
                {
                    title : "Image files", 
                    extensions : "jpg,gif,png"
                }
                ],
                resize : {
                    width : 700, 
                    height : 700, 
                    quality : 100
                },
                init : {
                    StateChanged: function(up) {
                        // Called when the state of the queue is changed
                        if(plupload.STOPPED){
                        }
                    }
                }
            });

            $('#uploadfiles').click(function(e) {

                $countfile = $('#filelist li').size();
                if($countfile > $nbfileauthorized){
                    alert("vous avez depassé la limite de fichiers autorisé : " + $countfile + " / " + $nbfileauthorized);
                }else{
                    uploader.start();

                }

                e.preventDefault();
            });

            uploader.init();

            uploader.bind('FilesAdded', function(up, files) {
                $.each(files, function(i, file) {
                    $('#filelist').append(
                        '<li class="clearfix plupload_delete" id="' + file.id + '">' +
                        "<div class='filename'>" + file.name + '</div><div class="filesize">' + plupload.formatSize(file.size) + '</div><div class="filestatus"></div>' +
                        '<div class="deletefile"><a id="deletefile" class="tooltip" title="supprimer la photo" href="#"><i class="icon-remove"></i></a></div></li>');
                });

                up.refresh(); // Reposition Flash/Silverlight
            });



            uploader.bind('UploadProgress', function(up, file) {
                $('#' + file.id).find('.filestatus').html(file.percent + "%");
            });

            uploader.bind('Error', function(up, err) {
                $('#filelist').append("<li class='clearfix'>Error: " + err.code +
                    ", Message: " + err.message +
                    (err.file ? ", File: " + err.file.name : "") +
                    "</li>"
                    );

                up.refresh(); // Reposition Flash/Silverlight
            });

            uploader.bind('FileUploaded', function(up, file) {
                $('#' + file.id).find('#deletefile').replaceWith("<i class='icon-ok'></i>");
            });
            uploader.bind('UploadComplete', function(up, files) {

                i = 0;
                for(var file in files){
                    $files.push(files[i].target_name);
                    i++;
                }

                $.ajax({
                    type: "GET",
                    dataType: "html",
                    cache: false,
                    data: {
                        files : $files,
                        cityid : $cityid
                    },
                    url: "/addphototemptodb",
                    success: function($photoid) {
                        $("#loader").hide(); 
                        if($photoid > 0){
                            openpopinedit($photoid, "newphoto");
                        }
                    }
                });
            });




        }
    });


}
4

0 回答 0