<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>葫芦侠免费图床</title>
<style>
body {
font-family: Arial, sans-serif;
background: url('https://api.suyanw.cn/api/comic') no-repeat center center fixed;
background-size: cover;
margin: 0;
padding: 0;
}
form {
max-width: 600px;
margin: 50px auto;
background-color: rgba(255, 255, 255, 0.8);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 80px;
border-radius: 50px;
}
h1 {
text-align: center;
margin-top: 0;
color: #333;
text-shadow: 1px 1px #fff;
}
label {
font-size: 14px;
font-weight: bold;
display: block;
margin-bottom: 5px;
}
input[type=file] {
display: block;
margin-bottom: 10px;
padding: 10px;
border: none;
border-radius: 3px;
background-color: rgba(255, 255, 255, 0.7);
box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);
}
input[type=submit] {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.2s ease-in-out;
}
input[type=submit]:hover {
background-color: #0066cc;
}
.status {
margin-top: 20px;
padding: 10px;
background-color: rgba(255, 255, 255, 0.7);
border-radius: 3px;
display: none;
}
.status.success {
background-color: #d4edda;
color: #155724;
border-color: #c3e6cb;
}
.status.error {
background-color: #f8d7da;
color: #721c24;
border-color: #f5c6cb;
}
</style>
</head>
<body>
<form action="#" method="POST" enctype="multipart/form-data" id="upload-form">
<h1>葫芦侠免费图床</h1>
<label for="file">选择一个图像文件:</label>
<input type="file" id="file" name="file" accept="image/*"><br>
<input type="submit" value="上传">
<div class="status" id="status"></div>
</form>
<script>
const form = document.getElementById('upload-form');
const status = document.getElementById('status');
form.addEventListener('submit', event => {
event.preventDefault();
status.style.display = 'none';
const fileInput = document.getElementById('file');
const file = fileInput.files[0];
if (!file) {
showError('Please choose a file to upload.');
return;
}
const formData = new FormData();
formData.append('file', file);
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
try {
const responseJson = JSON.parse(xhr.responseText);
const url = responseJson.url;
if (url) {
showSuccess(`图片网址 ${url}`);
} else {
showError('Failed to upload the image.');
}
} catch (error) {
showError('Failed to parse the response from the server.');
}
} else if (this.readyState === XMLHttpRequest.DONE) {
showError(`Server returned status code ${xhr.status}.`);
}
};
xhr.open('POST', 'https://api.suyanw.cn/huluxia/upload.php');
xhr.send(formData);
function showSuccess(message) {
status.textContent = message;
status.classList.remove('error');
status.classList.add('success');
status.style.display = 'block';
}
function showError(message) {
status.textContent = message;
status.classList.remove('success');
status.classList.add('error');
status.style.display = 'block';
}
});
</script>
</body>
</html>
小正太浩二
- 粉丝: 237
- 资源: 5944
最新资源
- (源码)基于Spring Boot框架的报表管理系统.zip
- (源码)基于树莓派和TensorFlow Lite的智能厨具环境监测系统.zip
- (源码)基于OpenCV和Arduino的面部追踪系统.zip
- (源码)基于C++和ZeroMQ的分布式系统中间件.zip
- (源码)基于SSM框架的学生信息管理系统.zip
- (源码)基于PyTorch框架的智能视频分析系统.zip
- (源码)基于STM32F1的Sybertooth电机驱动系统.zip
- (源码)基于PxMATRIX库的嵌入式系统显示与配置管理.zip
- (源码)基于虚幻引擎的舞蹈艺术节目包装系统.zip
- (源码)基于Dubbo和Redis的用户中台系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈