- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的服务器安装了 upload_progress 模块和 nginx。但我无法让它们正常工作。前端在html+javascript上的实现完全取自官网,不能出错。描述加载过程:我打开一个页面,看到进度条是空的,选择一个文件,按“提交”,然后翻到一个页面,文本:{“名称”:“”,“大小”:0, "type": null, "error": null},虽然我想看到填充进度条。我究竟做错了什么?
---nginx.conf
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 1024m;
access_log logs/access.log;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_proxied any;
gzip_min_length 1100;
gzip_http_version 1.0;
gzip_comp_level 9;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 80;
server_name localhost;
access_log logs/host.access.log;
location / {
root /var/www/;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 60;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_redirect default;
index index.html index.htm;
}
location ~* \.(jpg|jpeg|gif|png|css|js|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)
{
root /var/www/socnetwork;
index index.html index.php;
access_log off;
expires 30d;
}
}
---frontend.html
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>ajaxFileUpload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="./include/jquery/jquery-1.5.1.js"></script>
<script src="./include/jquery/jquery.uploadProgress.js"></script>
<script type="text/javascript">
$(function() {
$('form').uploadProgress({
jqueryPath: "./include/jquery/jquery-1.5.1.js",
uploadProgressPath: "./include/jquery/jquery.uploadProgress.js",
start:function(){},
uploading: function(upload) {$('#percents').html(upload.percents+'%');},
interval: 2000
});
});
</script>
<style type="text/css">
.bar {
width: 300px;
}
#progress {
background: #eee;
border: 1px solid #222;
margin-top: 20px;
}
#progressbar {
width: 0px;
height: 24px;
background: #333;
}
</style>
</head>
<body>
<form id="upload" enctype="multipart/form-data" action="index.html" method="post">
<input name="file" type="file"/>
<input type="submit" value="Upload"/>
</form>
<div id="uploading">
<div id="progress" class="bar">
<div id="progressbar"> </div>
</div>
</div>
<div id="percents"></div>
</body>
</html>
最佳答案
您需要在 nginx.conf 中设置 upload_progress 模块。查看示例 here .我在这里复制了关键元素:
http {
# reserve 1MB under the name 'proxied' to track uploads
upload_progress proxied 1m;
server {
....
location / {
...
# track uploads in the 'proxied' zone
# remember connections for 30s after they finished
track_uploads proxied 30s;
}
location ^~ /progress {
# report uploads tracked in the 'proxied' zone
report_uploads proxied;
}
} }
您可以向“/progress”发出 GET 请求以获取信息。
The HTTP request to this location must have a X-Progress-ID parameter or HTTP header containing a valid unique identifier of an inprogress upload.
关于linux - nginx 的 upload_progress 模块不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5895541/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!