mirror of
https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed.git
synced 2024-11-15 19:22:21 +08:00
aab76a77a3
新增GitHub仓库标签
94 lines
4.1 KiB
HTML
94 lines
4.1 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>文件上传</title>
|
||
<!--
|
||
本代码完全开源,仅供学习CloudFlare Page和Worker组件编程使用
|
||
仓库地址 https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed
|
||
不提供任何免费的技术支持、指导、问题解答,请按GitHub标准用法进行issue等方式交互
|
||
请勿滥用本代码,违规使用后果自负,任何操作和后果均与本人无关
|
||
API接口均需要使用者自行解决,本人不提供任何API接口服务
|
||
不得在中国大陆地区使用本代码
|
||
-->
|
||
<!-- 引入 Bootstrap CSS -->
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
|
||
<style>
|
||
.container {
|
||
margin-top: 50px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<a href="https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed" target="_blank" title="Visit GitHub Repository">
|
||
<img src="https://icons.iconarchive.com/icons/iconoir-team/iconoir/48/github-circle-icon.png" width="48" height="48">
|
||
</a>
|
||
<div class="container">
|
||
<h2>文件上传</h2>
|
||
<form id="upload-form">
|
||
<div class="form-group">
|
||
<label for="apiUrl">API 域名(请包含完整http开头,域名结尾不需要斜杠):</label>
|
||
<input type="text" class="form-control" id="apiUrl" placeholder="输入 API 域名" required>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="fileInput">选择文件</label>
|
||
<input type="file" class="form-control-file" id="fileInput" required>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="apiSelect">选择接口</label>
|
||
<select class="form-control" id="apiSelect">
|
||
<option value="58img">api-58img</option>
|
||
<option value="tgphimg">api-tgph-official</option>
|
||
</select>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary">上传</button>
|
||
</form>
|
||
<div id="result" class="mt-3" style="display: none;">
|
||
<label>返回的 URL:</label>
|
||
<input type="text" class="form-control" id="resultUrl" readonly>
|
||
<button class="btn btn-success mt-2" onclick="copyUrl()">复制 URL</button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 引入 jQuery 和 Bootstrap JS -->
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||
|
||
<script>
|
||
document.getElementById('upload-form').addEventListener('submit', function(e) {
|
||
e.preventDefault();
|
||
|
||
const apiUrlInput = document.getElementById('apiUrl');
|
||
const fileInput = document.getElementById('fileInput');
|
||
const apiSelect = document.getElementById('apiSelect');
|
||
const formData = new FormData();
|
||
formData.append('image', fileInput.files[0]);
|
||
|
||
// 使用用户输入的 API 域名和选择的接口构造完整的 URL
|
||
const apiUrl = `${apiUrlInput.value}/upload/${apiSelect.value}`;
|
||
console.log('API URL:', apiUrl);
|
||
|
||
fetch(apiUrl, {
|
||
method: 'POST',
|
||
body: formData,
|
||
})
|
||
.then(response => response.text())
|
||
.then(data => {
|
||
document.getElementById('resultUrl').value = data;
|
||
document.getElementById('result').style.display = 'block';
|
||
})
|
||
.catch(error => console.error('Error:', error));
|
||
});
|
||
|
||
function copyUrl() {
|
||
const copyText = document.getElementById('resultUrl');
|
||
copyText.select();
|
||
copyText.setSelectionRange(0, 99999); // 对于移动设备
|
||
document.execCommand('copy');
|
||
alert('URL 已复制');
|
||
}
|
||
</script>
|
||
</body>
|
||
</html>
|