198 lines
7.7 KiB
HTML
198 lines
7.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Network File Transfer</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
padding: 20px;
|
|
}
|
|
.container {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
max-width: 600px;
|
|
width: 100%;
|
|
padding: 40px;
|
|
}
|
|
h1 { color: #333; margin-bottom: 10px; text-align: center; }
|
|
.subtitle { text-align: center; color: #666; margin-bottom: 30px; font-size: 14px; }
|
|
.section { margin-bottom: 30px; }
|
|
.section h2 { font-size: 16px; color: #667eea; margin-bottom: 15px; border-bottom: 2px solid #667eea; padding-bottom: 8px; }
|
|
.upload-area {
|
|
border: 2px dashed #667eea;
|
|
border-radius: 8px;
|
|
padding: 30px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
background: #f8f9ff;
|
|
}
|
|
.upload-area:hover { background: #f0f2ff; border-color: #764ba2; }
|
|
.upload-area.dragover { background: #e8ebff; border-color: #764ba2; }
|
|
#fileInput { display: none; }
|
|
.btn {
|
|
display: inline-block;
|
|
background: #667eea;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
border-radius: 6px;
|
|
border: none;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
margin-top: 10px;
|
|
transition: background 0.3s;
|
|
}
|
|
.btn:hover { background: #764ba2; }
|
|
.btn-secondary { background: #6c757d; }
|
|
.btn-secondary:hover { background: #5a6268; }
|
|
.file-list {
|
|
background: #f8f9fa;
|
|
border-radius: 8px;
|
|
padding: 15px;
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
}
|
|
.file-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 10px;
|
|
background: white;
|
|
border-radius: 6px;
|
|
margin-bottom: 8px;
|
|
border-left: 4px solid #667eea;
|
|
}
|
|
.file-name { flex: 1; color: #333; word-break: break-all; font-size: 14px; }
|
|
.file-actions { display: flex; gap: 8px; margin-left: 10px; }
|
|
.btn-small { padding: 6px 12px; font-size: 12px; }
|
|
.message {
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
margin-bottom: 15px;
|
|
display: none;
|
|
font-size: 14px;
|
|
}
|
|
.message.show { display: block; }
|
|
.message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
|
|
.message.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
|
|
.no-files { text-align: center; color: #999; padding: 20px; font-size: 14px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>📁 Network File Transfer</h1>
|
|
<p class="subtitle">Upload and download files from your network drive</p>
|
|
<div id="message" class="message"></div>
|
|
|
|
<div class="section">
|
|
<h2>📤 Upload Files</h2>
|
|
<div class="upload-area" id="uploadArea">
|
|
<p>📁 Drag and drop files here</p>
|
|
<p style="font-size: 12px; color: #999;">or click to browse</p>
|
|
<button class="btn btn-secondary btn-small">Choose Files</button>
|
|
</div>
|
|
<input type="file" id="fileInput" multiple>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2>📥 Download Files</h2>
|
|
<div class="file-list" id="fileList">
|
|
<div class="no-files">Loading files...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const uploadArea = document.getElementById('uploadArea');
|
|
const fileInput = document.getElementById('fileInput');
|
|
const fileList = document.getElementById('fileList');
|
|
const message = document.getElementById('message');
|
|
|
|
uploadArea.addEventListener('click', () => fileInput.click());
|
|
uploadArea.addEventListener('dragover', (e) => {
|
|
e.preventDefault();
|
|
uploadArea.classList.add('dragover');
|
|
});
|
|
uploadArea.addEventListener('dragleave', () => uploadArea.classList.remove('dragover'));
|
|
uploadArea.addEventListener('drop', (e) => {
|
|
e.preventDefault();
|
|
uploadArea.classList.remove('dragover');
|
|
uploadFiles(e.dataTransfer.files);
|
|
});
|
|
fileInput.addEventListener('change', (e) => uploadFiles(e.target.files));
|
|
|
|
async function uploadFiles(files) {
|
|
for (let file of files) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
try {
|
|
const response = await fetch('/upload.sh', { method: 'POST', body: formData });
|
|
if (response.ok) {
|
|
showMessage(`✓ ${file.name} uploaded`, 'success');
|
|
loadFileList();
|
|
} else {
|
|
showMessage(`✗ Error uploading ${file.name}`, 'error');
|
|
}
|
|
} catch (error) {
|
|
showMessage(`✗ Error: ${error.message}`, 'error');
|
|
}
|
|
}
|
|
fileInput.value = '';
|
|
}
|
|
|
|
async function loadFileList() {
|
|
try {
|
|
const response = await fetch('/list.sh');
|
|
const text = await response.text();
|
|
const files = text.trim().split('\n').filter(f => f);
|
|
fileList.innerHTML = files.length === 0
|
|
? '<div class="no-files">No files yet</div>'
|
|
: files.map(file => `
|
|
<div class="file-item">
|
|
<span class="file-name">${file}</span>
|
|
<div class="file-actions">
|
|
<a href="/download.sh?file=${encodeURIComponent(file)}" class="btn btn-small">Download</a>
|
|
<button class="btn btn-small" style="background: #dc3545;" onclick="deleteFile('${file}')">Delete</button>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
} catch (error) {
|
|
fileList.innerHTML = '<div class="no-files">Error loading files</div>';
|
|
}
|
|
}
|
|
|
|
async function deleteFile(filename) {
|
|
if (!confirm(`Delete ${filename}?`)) return;
|
|
try {
|
|
const response = await fetch(`/delete.sh?file=${encodeURIComponent(filename)}`, { method: 'POST' });
|
|
if (response.ok) {
|
|
showMessage(`✓ ${filename} deleted`, 'success');
|
|
loadFileList();
|
|
} else {
|
|
showMessage(`✗ Error deleting ${filename}`, 'error');
|
|
}
|
|
} catch (error) {
|
|
showMessage(`✗ Error: ${error.message}`, 'error');
|
|
}
|
|
}
|
|
|
|
function showMessage(text, type) {
|
|
message.textContent = text;
|
|
message.className = `message show ${type}`;
|
|
setTimeout(() => message.classList.remove('show'), 4000);
|
|
}
|
|
|
|
loadFileList();
|
|
setInterval(loadFileList, 5000);
|
|
</script>
|
|
</body>
|
|
</html>
|