You may limit the maximum number of image upload using API related to the file upload provided by Synap Editor.
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); // You must use this to check the file uploaded through editor.getUploadedFiles() }); editor.setEventListener('beforeUploadImage', function (e) { var fileType = e.fileType; var uploadCount = e.uploadCount; //Number of files being uploaded (the number of files to be uploaded whose upload is not completed yet) var imageCount = 0; e.editor.getUploadedFiles(fileType).forEach(function (info) { if (!info.isDeleted) { imageCount++; // Count the number of images not deleted } }); if (imageCount + uploadCount >= 5) { // Allow up to 5 uploads e.returnValue = false; // Cancel the upload by returning false through returnValue alert('Five images can be uploaded at most'); } });
Relevant APIs