The pure JS (TS) upload library with no dependencies compatible with Google Chrome, Firefox, IE10+ (IE9- with auto-start by default, manual-start optionally) and mobile browsers.
- Dowload as a ZIP file directly from GitHub pages and include to your project.
- Install with npm by
npm install pure-upload --save
. - Install with bower by
bower install pure-upload
.
See a simple example.
Uploader manages upload queue and registers upload areas.
Initialization:
let uploader = pu.getUploader(uploadQueueOptions, uploadQueueCallbacks)
maxParallelUploads?: number;
autoStart?: boolean;
autoRemove?: boolean;
onProgressCallback?: (file: IUploadFile) => void;
onCancelledCallback?: (file: IUploadFile) => void;
onFinishedCallback?: (file: IUploadFile) => void;
onUploadedCallback?: (file: IUploadFile) => void;
onErrorCallback?: (file: IUploadFile) => void;
onUploadStartedCallback?: (file: IUploadFile) => void;
onFileAddedCallback?: (file: IUploadFile) => void;
onFileRemovedCallback?: (file: IUploadFile) => void;
onAllFinishedCallback?: () => void;
onQueueChangedCallback?: (queue: IUploadFile[]) => void;
onFilesAddedErrorCallback?: (files: IUploadFile[]) => void;
Upload area defines element registred in Uploader.
Registration:
let uploadArea = uploader.registerArea(element, uploadAreaOptions);
Registration for IE9- with manual-start:
let uploadArea = uploader.registerArea(element, uploadAreaOptions, compatibilityForm);
The compatibilityForm objects has to be form element containing one input element for file and one input element for submit.
Unregistration:
uploader.unregisterArea(uploadArea);
url: string;
method: string;
withCredentials?: boolean;
headers?: { [key: string]: string; };
params?: { [key: string]: string; };
maxFileSize?: number;
allowDragDrop?: boolean;
clickable?: boolean;
accept?: string;
multiple?: boolean;
onFileAdded?: (file: IUploadFile) => void;
onFileError?: (file: IUploadFile) => void;
onFileCancelled?: (file: IUploadFile) => void;
Standard File object extended with additional informations and methods to manage a file in queue.
guid: string;
uploadStatus: UploadStatus;
responseCode: number;
responseText: string;
progress: number;
sentBytes: number;
cancel: () => void;
remove: () => void;
start: () => void;
File statuses accesible by pu.uploadStatus
.
Library used by GMC Software Technology.
MIT, Copyright © 2015 Tomáš Růt