PHP Classes

File: resources/js/Compositions/file-uploader.js

Recommend this page to a friend!
  Classes of Robert Devenyi   Iceburg CRM   resources/js/Compositions/file-uploader.js   Download  
File: resources/js/Compositions/file-uploader.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Iceburg CRM
CRM application to manage contacts
Author: By
Last change:
Date: 1 year ago
Size: 772 bytes
 

Contents

Class file image Download
export async function uploadFile(file, url) { // set up the request data let formData = new FormData() formData.append('file', file.file) // track status and upload file file.status = 'loading' let response = await fetch(url, { method: 'POST', body: formData }) // change status to indicate the success of the upload request file.status = response.ok return response } export function uploadFiles(files, url) { return Promise.all(files.map((file) => uploadFile(file, url))) } export default function createUploader(url) { return { uploadFile: function (file) { return uploadFile(file, url) }, uploadFiles: function (files) { return uploadFiles(files, url) }, } }