2012-05-23 1 views
5

웹 사이트의 사용자 정의 예제를 기반으로 인스턴스를 plupload했습니다. 서버 측 업로드 스크립트 (예제의 upload.php)에서 오는 오류 메시지를 표시하는 것을 제외하고는 완벽하게 작동합니다. 다운로드 폴더).plUpload - 서버 측 오류가 표시되지 않습니다.

로컬 오류 메시지가 표시되고 있습니다. 예를 들어 제한된 파일 형식을 업로드하려고하면 서버 쪽 메시지가 표시되지 않는 오류 메시지가 나타납니다.

업로드가 성공적으로 처리되면 upload.php 파일이 제대로 트리거되고 있으며 파일을 요청하고 있는지 확인하기 위해 절전 기능을 설정했습니다. 10 초 동안 잠자기 상태에서 오류 메시지를 반환하는 디버깅을 돕기 위해 upload.php 상단에 줄을 긋기 만해도 여전히 작동하지 않습니다. 나는 이미 너무 오래 지출 가지고

upload.php 
    sleep(10); 
    die('{"jsonrpc" : "2.0", "error" : {"code": 500, "message": "THIS IS AN ERROR."}, "id" : "id"}'); 
...(Rest of normal upload.php file)... 

내가 아래에 포함되어 있습니다 사용하고 자바 스크립트는 너희들이 줄 수있는 모든 도움을 주시면 감사하겠습니다과 문제는 라이브 내 코드를 밀어 수있는에서 날 다시 들고 .

감사합니다,

알렉스 여기

// Fanart 
$(function() { 
var fanart_uploader = new plupload.Uploader({ 
    runtimes : 'html5,flash,html4', 
    browse_button : 'fanart_pickfiles', 
    container : 'fanart_container', 
    drop_element : 'fanart_drop', 
    chunk_size : '1mb', 
    max_file_size : '8mb', 
    url : '/upload.php?gameid=<?= $gameid ?>&arttype=fanart', 
    flash_swf_url : '/js/plupload/js/plupload.flash.swf', 
    silverlight_xap_url : '/js/plupload/js/plupload.silverlight.xap', 
    filters : [ 
     {title : "Image files", extensions : "jpg,png"}, 
    ] 
}); 

fanart_uploader.bind('Init', function(up, params) { 
    $('#fanart_runtime').html("You are using " + params.runtime); 
}); 

$('#fanart_uploadfiles').click(function(e) { 
    fanart_uploader.start(); 
    e.preventDefault(); 
}); 

fanart_uploader.init(); 

fanart_uploader.bind('FilesAdded', function(up, files) { 
    $.each(files, function(i, file) { 
     $('#fanart_filelist').append(
      '<div style="padding: 4px; margin: 3px; border: 1px dotted #fff; border-radius: 6px; background-color: #333;" id="' + file.id + '"><img class="tick" src=\"<?= $baseurl ?>/images/common/icons/tick_16.png\" style=\"display: none; vertical-align: -2px;\" />' + 
      file.name + ' <em>(' + plupload.formatSize(file.size) + ')</em> <div style=\"margin: auto; margin-top: 3px; width: 200px; height: 20px; border: 1px solid #fff; border-radius: 6px; background-color: #222;\"><div class="progressbar" style=\"width: 0px; height: 16px; padding: 2px 0px; background-color: #ccc; border-radius: 6px; text-align: center;\"><b style="font-size: 16px; color: #222;"></b></div></div>' + 
     '</div>'); 
    }); 

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

fanart_uploader.bind('UploadProgress', function(up, file) { 
    $('#' + file.id + " b").html(file.percent + "%"); 
    $('#' + file.id + " .progressbar").css("width", (file.percent * 2)); 
}); 

fanart_uploader.bind('Error', function(up, err) { 
    $('#fanart_filelist').append("<div>Error: " + err.code + 
     ", Message: " + err.message + 
     (err.file ? ", File: " + err.file.name : "") + 
     "</div>" 
    ); 

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

fanart_uploader.bind('FileUploaded', function(up, file) { 
    $('#' + file.id + " .tick").show(); 
}); 
}); 
+0

나노, 내 자신의 질문에 대답 ... 스택 오버플로가 내 자신의 대답을 넣어 보자 않을 것이다, 그래서 당신은 여기 내 대답을 찾을 수 있습니다 - http://www.plupload.com/punbb/viewtopic .php? id = 1804 – flexage

답변

10

그리고 당신이에 링크 된 답변입니다 :

NM, 내 자신의 질문에 대답 ...

그것은 내 plUpload 보인다 예 : JSON 문자열을 통해 액세스 할 수있는 JS 객체로 서버 응답을 해제합니다. "FileUploaded"이벤트입니다.

이것은이 답변이 필요한 사람들을위한 코드 예제입니다.

fanart_uploader.bind('FileUploaded', function(up, file, info) { 
    $('#' + file.id + " .tick").show(); 
    printObject(info); 

    var response = jQuery.parseJSON(info.response); 

    alert(response.error.message); 
}); 
+0

나를 보내 주셔서 감사합니다;) – flexage