MCPcopy Create free account
hub / github.com/error311/FileRise / processFiles

Function processFiles

public/js/upload.js:1048–1163  ·  view source on GitHub ↗
(filesInput)

Source from the content-addressed store, hash-verified

1046 - Used for XHR fallback + grouping in the upload UI.
1047------------------------------------------------------ */
1048function processFiles(filesInput) {
1049 const fileInfoContainer = document.getElementById("fileInfoContainer");
1050 const files = Array.from(filesInput);
1051
1052 if (fileInfoContainer) {
1053 if (files.length > 0) {
1054 if (files.length === 1) {
1055 fileInfoContainer.innerHTML = `
1056 <div id="filePreviewContainer" class="file-preview-container" style="display:inline-block;">
1057 <span class="material-icons file-icon">insert_drive_file</span>
1058 </div>
1059 <span id="fileNameDisplay" class="file-name-display">${escapeHTML(files[0].name || files[0].fileName || "Unnamed File")}</span>
1060 `;
1061 } else {
1062 fileInfoContainer.innerHTML = `
1063 <div id="filePreviewContainer" class="file-preview-container" style="display:inline-block;">
1064 <span class="material-icons file-icon">insert_drive_file</span>
1065 </div>
1066 <span id="fileCountDisplay" class="file-name-display">${files.length} files selected</span>
1067 `;
1068 }
1069 const previewContainer = document.getElementById("filePreviewContainer");
1070 if (previewContainer) {
1071 previewContainer.innerHTML = "";
1072 displayFilePreview(files[0].file || files[0], previewContainer);
1073 }
1074 } else {
1075 fileInfoContainer.innerHTML = `<span id="fileInfoDefault">No files selected</span>`;
1076 }
1077 }
1078
1079 files.forEach((file, index) => {
1080 file.uploadIndex = index;
1081 });
1082
1083 const progressContainer = document.getElementById("uploadProgressContainer");
1084 progressContainer.innerHTML = "";
1085
1086 if (files.length > 0) {
1087 const maxDisplay = 10;
1088 const list = document.createElement("ul");
1089 list.classList.add("upload-progress-list");
1090
1091 // Check for relative paths (for folder uploads).
1092 const hasRelativePaths = files.some(file => {
1093 const rel = file.webkitRelativePath || file.customRelativePath || "";
1094 return rel.trim() !== "";
1095 });
1096
1097 if (hasRelativePaths) {
1098 // Group files by folder.
1099 const fileGroups = {};
1100 files.forEach(file => {
1101 let folderName = "Root";
1102 const relativePath = file.webkitRelativePath || file.customRelativePath || "";
1103 if (relativePath.trim() !== "") {
1104 const parts = relativePath.split("/");
1105 if (parts.length > 1) {

Callers 3

wireFileInputChangeFunction · 0.85
queueResumableFilesFunction · 0.85
submitFilesFunction · 0.85

Calls 7

escapeHTMLFunction · 0.85
displayFilePreviewFunction · 0.85
createFileEntryFunction · 0.85
updateFileInfoCountFunction · 0.85
setUploadButtonVisibleFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected