202506 - 双虹云博客-站长博客|网站源码|emlog Pro|软件模板|QQZZZ.CN
首页 源码插件 代码笔记 精品资源 美图音乐 点滴记忆 关于博主 友情链接

热门搜索

  • 360官方API构建高效便捷的图片上传单页源码
侧边栏壁纸
博主头像
BingGan

她说爱你,没说只爱你!

  • 累计撰写 100 篇文章
  • 累计收到 54 条评论
  • 首页
  • 导航
    • 首页
    • 源码插件
    • 代码笔记
    • 精品资源
    • 美图音乐
    • 点滴记忆
    • 关于博主
    • 友情链接
  • 旗下站点
    • Bg‖ 在线音乐
    • Bg‖ Mail邮件
    • Bg‖ SEO外链
存档于 【202506】 的文章
  • 360官方API构建高效便捷的图片上传单页源码 2025-6-24
    360官方API构建高效便捷的图片上传单页源码 页面采用了响应式设计原则,确保在各种设备上都能提供良好的用户体验。通过meta viewport标签设置视口属性,保证页面能适应不同屏幕尺寸。 新建一个html单页把源码复制进去,然后修改背景图路径即可。 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>360图床文件上传 - 双虹云博客</title> <style> /* 重置默认样式 */ * { margin: 0; padding: 0; box-sizing: border-box; } /* 设置页面的字体和添加背景图片 */ body { font-family: Arial, sans-serif; background: url('static/images/background.png') no-repeat center center fixed; /* 使用服务器上的路径 */ background-size: cover; /* 保证背景图片覆盖整个视窗 */ color: #333; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; } /* 容器样式 */ .container { background-color: rgba(255, 255, 255, 0.9); /* 使用半透明白色背景,以便在图片背景上更清晰地显示内容 */ padding: 30px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); width: 100%; max-width: 500px; text-align: center; } /* 标题样式 */ h2 { font-size: 24px; margin-bottom: 20px; color: #333; } /* 文件输入框样式 */ input[type="file"] { display: block; margin: 0 auto 20px; padding: 8px; background-color: #f7f7f7; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; color: #333; } /* 按钮样式 */ button { background-color: #007BFF; color: #fff; padding: 12px 20px; font-size: 16px; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease; } /* 按钮悬浮效果 */ button:hover { background-color: #0056b3; } /* 进度条样式 */ .progress-bar { width: 100%; height: 30px; background-color: #ddd; border-radius: 4px; margin-top: 20px; overflow: hidden; } .progress-fill { height: 100%; background-color: #4caf50; width: 0; line-height: 30px; text-align: center; color: white; } /* 上传结果区域样式 */ .result { margin-top: 20px; padding: 10px; border: 1px solid #ccc; border-radius: 4px; background-color: #f9f9f9; font-size: 16px; color: #333; min-height: 40px; } /* 错误或成功的提示信息样式 */ .result.success { border-color: #28a745; background-color: #e9f7e8; } .result.error { border-color: #dc3545; background-color: #f8d7da; } /* 显示图片的样式 */ .uploaded-image { margin-top: 20px; max-width: 100%; height: auto; border-radius: 4px; border: 1px solid #ddd; } </style> </head> <body> <div class="container"> <h2>图片上传-双虹云</h2> <form id="uploadForm"> <input type="file" id="fileInput" name="file" accept="image/*" required /> <button type="submit">上传文件</button> </form> <div id="result" class="result"></div> <!-- 进度条 --> <div class="progress-bar"> <div class="progress-fill" id="progressFill">0%</div> </div> </div> <script> const form = document.getElementById('uploadForm'); const resultDiv = document.getElementById('result'); const progressBar = document.querySelector('.progress-fill'); form.addEventListener('submit', (e) => { e.preventDefault(); const fileInput = document.getElementById('fileInput'); const file = fileInput.files[0]; if (!file) { resultDiv.innerHTML = '<p class="error">请先选择文件!</p>'; return; } const formData = new FormData(); formData.append('file', file); const xhr = new XMLHttpRequest(); xhr.open('POST', 'https://api.xinyew.cn/api/360tc', true); // 监听上传进度事件 xhr.upload.onprogress = function(event) { if (event.lengthComputable) { const percentComplete = (event.loaded / event.total) * 100; progressBar.style.width = percentComplete + '%'; progressBar.innerHTML = Math.round(percentComplete) + '%'; } }; xhr.onload = function() { if (xhr.status === 200) { const data = JSON.parse(xhr.responseText); if (data.errno === 0) { resultDiv.innerHTML = ` <p>上传成功!</p> <p>图片链接: <a href="${data.data.url}" target="_blank">${data.data.url}</a></p> <p>图片文件名: ${data.data.imgFile}</p> <img src="${data.data.url}" alt="上传的图片" class="uploaded-image" /> `; } else { resultDiv.innerHTML = `<p class="error">${data.error}</p>`; } } else { resultDiv.innerHTML = `<p class="error">请求失败:${xhr.statusText}</p>`; } }; xhr.onerror = function() { resultDiv.innerHTML = '<p class="error">请求发生错误。</p>'; }; xhr.send(formData); }); </script> </body> </html>
    • 2025年-6月-24日
    • 21 阅读
    • 0 评论
    代码笔记
博主栏壁纸
博主头像 BingGan

她说爱你,没说只爱你!

100 文章数
54 评论量
  • 360官方API构建高效便捷的图片上传单页源码
微语
  • BingGan
    2024-08-08 01:44

    我的👶今天满月了🎈

  • BingGan
    2024-03-28 12:05

    浪漫固然重要,但真诚更胜一筹

  • BingGan
    2024-03-24 20:51

    不是电影里的一瞬间 是实实在在的一年365天。

标签
火山引擎 吾爱论坛 吾爱破解 搜索引擎 网站收录 Virtual Audio Cable WaterDrop 引流宝 IP归属地查询 IP地址获取 IP IP查询 BeaconNav Typecho 短网址 Nginx 奇安信 OneTool 蜘蛛日志 SSL 站长工具 emlog插件 go跳转 go 前端 DNS 网页特效 js emlo SU7
分类
  • 点滴记忆  (19)
  • 源码分享  (39)
  • 代码笔记  (21)
  • 美图音乐  (18)
  • 精品资源  (2)
热门文章
  1. 1 360官方API构建高效便捷的图片上传单页源码
    360官方API构建高效便捷的图片上传单页源码
    21 阅读 - 06月24日
舔狗日记
载入天数...载入时分秒...
sitemap
powered by emlog 皖ICP备17001127号-30