文件传不到服务器上,文件上传不到FTP服务器

所有软件都是在windows环境下的

1.FTP服务器的配置:

4992f8a1c4bd31b39d4f1c3d6bfcdb0b.png

2.Nginx的配置:

(1)nginx.conf文件

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '

# '$status $body_bytes_sent "$http_referer" '

# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root html;

index index.html index.htm;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

# proxy_pass http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

#location ~ \.php$ {

# root html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

# include fastcgi_params;

#}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

# deny all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

# listen 8000;

# listen somename:8080;

# server_name somename alias another.alias;

# location / {

# root html;

# index index.html index.htm;

# }

#}

include vhost/*.conf;

# HTTPS server

#

#server {

# listen 443 ssl;

# server_name localhost;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;

# ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

}

(2)image.imooc.com.conf文件

server {

listen 80;

autoindex off;

server_name image.imooc.com;

access_log c:/access.log combined;

index index.html index.htm index.jsp index.php;

#error_page 404 /404.html;

if ( $query_string ~* ".*[\;'\].*" ){

return 404;

}

location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {

deny all;

}

location / {

root C:\ftpfile\img;

add_header Access-Control-Allow-Origin *;

}

}

3.我直接访问C:\ftpfile\img\QQ截图20190114201007.png,是可以访问到的,如下图所示:

c4194bec5f49aa52e8c24698f4a07754.png

我直接访问127.0.0.1,出现nginx的欢迎界面,如下图所示:

fb69e242e3f2e5462f9f4247458a884f.png

我访问ftp://localhost/img/,也是完全没有问题的,如下图所示:

edd8d5d756040d53fb99c3afaf7f2b02.png

我访问http://image.imooc.com/QQ%E6%88%AA%E5%9B%BE20190114201007.png,也是没有问题的,如下图所示:

2a9291ac3371be6dd3798560ae909223.png

4.上面写了这么多,只是想证明我的FTP服务器和Nginx都是配置正常的,下面说说我的问题。

我刚看完8-7小节,上传文件到FTP服务器失败了。

首先是index.jsp页面:

d090ca973c01fb5b3f3f63cb8db66e1a.png

我点击上图红框中的上传文件按钮,跳转到下图:

eb2b6041afdd5ac04249c4b74fb4892c.png

我在新标签页中打开上述链接,报404错误,如下图。

f632dba11b46e5a605083d20dfadfc4b.png

我查看我的FTP文件夹,没有上传过来,所以上图报了404错误。

ef9015422f27f5ec1627bb512fac499f.png

我将上图红框中的代码注释掉,想查看文件是否上传到了Tomcat对应的文件夹下,发现是上传成功的,如下图所示:

611efdcb91cd56133f7b4e3d466dd50b.png

所以我是在Tomcat上传到FTP这个过程中出现了问题,但是idea没有报任何错误信息。

215408ee4d27b25081c7234be84d594d.png

完全不知道如何解决。

我搜索过问答区类似的问题:链接描述

上面这位哥们和我遇到的问题很相似,但是我不清楚他是怎么解决的。我也试了他里面说的把下图红框中的"img"换为"",没有效果。

10d5262cd32358a32494d1e498bd2c23.png

上图蓝色方框内的remotePath,我不知道这个变量是做什么用的,还有后面的changeWorkingDirectory是在做什么?

提问不易,希望老师能认真解答。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值