Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

API Name

...

Status
Status
colourYellow
title릴리즈 2.2.1 이상

파일 타입별 업로드된 파일의 경로와 경로(path), 삭제되었는지 와 삭제 여부(isDeleted)를 Object 형태로 반환합니다파일 타입별로 반환합니다.

이 함수에서 적절한 정보를 얻어오려면 afterUploadFile, afterUploadImage, afterUploadVideo 이벤트에서 addUploadPath를 이용해서 업로드된 파일정보를 추가해주어야 합니다.

Parameters:

Name

Type

Description

[fileType]string정보를 가져올 파일 타입입니다. ("image", "video", "file")


Return:

[fileType이 있는 경우]

...

TypeAttributeDescription
Array
[
	{ path: "/upload/path/filename.png", isDeleted: false },
	{ path: "/upload/path/filename2.png", isDeleted: true },
	//....
]

path

경로와, isDeleted 삭제여부 데이터

Example:

Code Block
languagejs
themeEmacs
var filesData = editor.getUploadedFiles();

...

Status
title릴리즈 2.2.1 이상

파일 타입별 업로드된 파일의 경로와 (path), 삭제되었는지 여부 (isDeleted) 를 Object 형태로 반환합니다.

Parameters:

...

Name

...

Type

...

Description

...

: 업로드 경로

isDeleted: 에디터에서 해당 파일의 삭제 여부

[fileType이 없는 경우]

TypeAttributeDescription
Object
{
	image: [
		{ path: "/upload/path/filename.png", isDeleted: false },
		{ path: "/upload/path/filename2.png", isDeleted: true },
		.//...
	],
	video: [],
	file: []
}

path

경로와, isDeleted 삭제여부 데이터

: 업로드 경로

isDeleted: 에디터에서 해당 파일의 삭제 여부

Example:

Code Block
languagejs
themeEmacs
var filesData = editor.getUploadedFiles();

활용 예

1. 이미지 업로드 수 제한하기

Code Block
languagejs
var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var editor = new SynapEditor(editorId, editorConfig, html);

editor.setEventListener('afterUploadImage', function (e) {
	var fileType = e.fileType;
	var uploadPath = e.path;
	e.editor.addUploadPath(fileType, uploadPath); // editor.getUploadedFiles() 을 통해 업로드된 파일을 확인하려면 반드시 사용
});

editor.setEventListener('beforeUploadImage', function (e) {
	var fileType = e.fileType;
	var uploadCount = e.uploadCount; // 업로드 중인 이미지 수 (아직 업로드 되지 않은)
	var imageCount = 0;
	e.editor.getUploadedFiles(fileType).forEach(function (info) {
		if (!info.isDeleted) {
			imageCount++; // 삭제되지 않은 이미지 개수 세기
		}
	});
	if (imageCount + uploadCount >= 5) { // 5개 까지만 허용하기
		e.returnValue = false; // returnValue로 false를 반환해 업로드를 취소
		alert('이미지는 5개까지만 업로드 가능합니다');
	}
});
var filesData2 = editor.getUploadedFiles('image');


...

활용 예

1. 이미지 업로드 수 제한하기

Include Page
DEMO:이미지 업로드 수 제한하기
DEMO:이미지 업로드 수 제한하기