Add Upload Component for Files Component
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Neutral/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Neutral/pipeline/head This commit looks good
				
			This commit is contained in:
		@@ -8,6 +8,7 @@
 | 
			
		||||
                    <h1><i class="fa fa-folder"></i> Fichiers</h1>
 | 
			
		||||
                    <div>
 | 
			
		||||
                        <button id="fi_new_folder" class="fi_act_btn"><i class="fa fa-folder"></i> Nouveau dossier</button>
 | 
			
		||||
                        <input id='fi_upload_file' type='file' hidden multiple />
 | 
			
		||||
                        <button id="fi_upload" class="fi_act_btn"><i class="fa fa-upload"></i> Upload</button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
@@ -154,10 +155,72 @@
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        const uploadBtn = document.getElementById("fi_upload")
 | 
			
		||||
        const uploadFiles = document.getElementById("fi_upload_file")
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        uploadBtn.addEventListener("click", () => {
 | 
			
		||||
 | 
			
		||||
            document.getElementById("_rename").showModal()
 | 
			
		||||
            uploadFiles.click()
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        uploadFiles.addEventListener("change", () => {
 | 
			
		||||
 | 
			
		||||
            var stopSend = false
 | 
			
		||||
            fiInfo.innerHTML = ""
 | 
			
		||||
 | 
			
		||||
            for(var file of uploadFiles.files) {
 | 
			
		||||
 | 
			
		||||
               
 | 
			
		||||
 | 
			
		||||
                if(stopSend == false) {
 | 
			
		||||
                    const file_acc = new FormData();
 | 
			
		||||
                    file_acc.append("apic", file)
 | 
			
		||||
                                                            
 | 
			
		||||
                fetch('/upload', {
 | 
			
		||||
                    method: 'POST',
 | 
			
		||||
                    mode:"cors",
 | 
			
		||||
                    cache:"no-cache",
 | 
			
		||||
                    credentials:"same-origin",
 | 
			
		||||
                    headers: {
 | 
			
		||||
                        "uploadfiledirectory": currentDir.value
 | 
			
		||||
 | 
			
		||||
                    },
 | 
			
		||||
                    referrerPolicy:"no-referrer",
 | 
			
		||||
                    redirect: 'follow',
 | 
			
		||||
                    body: file_acc
 | 
			
		||||
                }).then(response => response.json())
 | 
			
		||||
                .then(response => resupload(response))
 | 
			
		||||
 | 
			
		||||
                function resupload(response) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    if(response.result == "ERROR") {
 | 
			
		||||
                        fiInfo.innerHTML = "Les fichiers n'ont pas pu être uploadés !"
 | 
			
		||||
                        stopSend = true
 | 
			
		||||
                    
 | 
			
		||||
                    } else {
 | 
			
		||||
 | 
			
		||||
                        getDirectory(currentDir.value)
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                } 
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            uploadFiles.value = null
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
           
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        currentDir.addEventListener("change", () => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user