|
Param |
Method |
Event |
|
|
UploadProcv4.3.2.32 or higher이미지 업로드 시 고객사의 파일 업로드 모듈을 호출하여 실행합니다. 에디터에서 이미지 업로드 시 에디터 내부 업로드가 동작하지 않고 설정한 함수가 호출됩니다. 호출 시 파라미터로 넘어오는 object 값을 사용하여 업로드를 진행합니다. 모던 웹 브라우저에서 지원이 가능합니다.
- 적용 대상 : 그림 넣기, Copy&Paste, Drag&Drop, 배경 그림, 표 배경 그림, 셀 배경 그림, 파일 넣기, 동영상
Parameters
Sample Codesvar CrossEditor = new NamoSE("test");
CrossEditor.params.event.UploadProc = function(obj){
var newFormData = new FormData(); //Object정보를 담을 새로운 formData
if(obj.dataObj.plugins && obj.files){ //오피스플러그인 모드일 경우
for(var i = 0; i<obj.files.length; i++){
newFormData.append(obj.files[i].inputFileName, obj.files[i].blob, obj.files[i].filename);
}
}
Object.keys(obj.dataObj).forEach(function(key){
newFormData.append(key, obj.dataObj[key]); //Object정보를 formData에 설정
console.log(key + ' | ' + obj.dataObj[key]);
});
var xhr = new XMLHttpRequest();
if(obj.dataObj.plugins){ //오피스플러그인 모드 Copy&Paste
xhr.open('POST', "이미지 업로드 url"); //이미지업로드 url
} else{
if(obj.dataObj.fileKind == "image" || obj.dataObj.imageKind == "image"){
url = "이미지 업로드 url";
}else if(obj.dataObj.fileKind == "file" || obj.dataObj.imageKind == "file"){
url = "파일 업로드 url";
}else if(obj.dataObj.fileKind == "flash" || obj.dataObj.imageKind =="flash"){
url = "동영상 업로드 url";
}else if(obj.dataObj.imageKind == "backgroundimage"){ // 배경그림 넣기 경우 처리 추가
url = "배경그림 업로드 url";
}
xhr.open('POST', url); //savePathURL
}
xhr.onload = function () {
if (xhr.status === 200) {
obj.complete(xhr.responseText); //업로드 성공 후에 호출
}else{ //onerror가 발생하지 않는 경우 예외처리 (IE)
if(!obj.dataObj.plugins){
obj.error("upload fail!!");
} else{
obj.error("plugin mode_upload fail!")
}
}
};
xhr.onerror = function(){ //업로드 실패 시에 호출
if(!obj.dataObj.plugins){
obj.error("upload fail!!");
}else{
obj.error("plugin mode_upload fail!")
}
};
xhr.send(newFormData); //formData 설정
}
CrossEditor.EditorStart();
|