当前位置: 首页 > news >正文

南京网站设计培训价格ip网站查询服务器

南京网站设计培训价格,ip网站查询服务器,网站建设哪家靠谱,公司注册咨询电话简介 FTP(File Transfer Protocol,文件传输协议) 是 TCP/IP 协议组中的协议之一。FTP协议包括两个组成部分,其一为FTP服务器,其二为FTP客户端。其中FTP服务器用来存储文件,用户可以使用FTP客户端通过FTP协…

简介

FTP(File Transfer Protocol,文件传输协议) 是 TCP/IP 协议组中的协议之一。FTP协议包括两个组成部分,其一为FTP服务器,其二为FTP客户端。其中FTP服务器用来存储文件,用户可以使用FTP客户端通过FTP协议访问位于FTP服务器上的资源。在开发网站的时候,通常利用FTP协议把网页或程序传到Web服务器上。此外,由于FTP传输效率非常高,在网络上传输大的文件时,一般也采用该协议。

默认情况下FTP协议使用TCP端口中的 20和21这两个端口,其中20用于传输数据,21用于传输控制信息。但是,是否使用20作为传输数据的端口与FTP使用的传输模式有关,如果采用主动模式,那么数据传输端口就是20;如果采用被动模式,则具体最终使用哪个端口要服务器端和客户端协商决定。

FTP服务器搭建

FileZilla Server 是一款小巧的FTP服务器软件,若你想玩玩简单的ftp服务器,那你可以试试这个耗用系统资源相当小的软件,让你轻松又容易架设一FTP服务器,新增组配置,上传及下载速度限制,用户在线显示及踢除。

下载安装说明文档在百度云盘里,自行下载:

链接:https://pan.baidu.com/s/1Kr5k-HmIl9VRA9cx4paDRA
提取码:uyfa

服务器安装好了,就可以在浏览器输入ftp://127.0.0.1查看是否搭建成功,输入自己设置的用户及密码:

image-20210429091036816.png

文件的上传与下载

上传

将自己D盘下的一张图片上传到ftp服务器

kebi.jpg

    /*** 向FTP服务器上传文件** @param host     FTP服务器hostname* @param port     FTP服务器端口* @param username FTP登录账号* @param password FTP登录密码* @param basePath FTP服务器基础目录* @param filePath FTP服务器文件存放路径。例如分日期存放:/2015/01/01。文件的路径为basePath+filePath* @param filename 上传到FTP服务器上的文件名* @param input    本地要上传的文件的 输入流* @return 成功返回true,否则返回false*/public static boolean uploadFile(String host, int port, String username, String password, String basePath,String filePath, String filename, InputStream input) {boolean result = false;FTPClient ftp = new FTPClient();try {int reply;ftp.connect(host, port);// 连接FTP服务器// 如果采用默认端口,可以使用ftp.connect(host)的方式直接连接FTP服务器ftp.login(username, password);// 登录reply = ftp.getReplyCode();if (!FTPReply.isPositiveCompletion(reply)) {ftp.disconnect();return result;}//切换到上传目录if (!ftp.changeWorkingDirectory(basePath + filePath)) {//如果目录不存在创建目录String[] dirs = filePath.split("/");String tempPath = basePath;for (String dir : dirs) {if (null == dir || "".equals(dir)) continue;tempPath += "/" + dir;if (!ftp.changeWorkingDirectory(tempPath)) {if (!ftp.makeDirectory(tempPath)) {return result;} else {ftp.changeWorkingDirectory(tempPath);}}}}//设置上传文件的类型为二进制类型ftp.setFileType(FTP.BINARY_FILE_TYPE);//上传文件if (!ftp.storeFile(filename, input)) {return result;}input.close();ftp.logout();result = true;} catch (IOException e) {e.printStackTrace();} finally {if (ftp.isConnected()) {try {ftp.disconnect();} catch (IOException ioe) {}}}return result;}public static void main(String[] args) {try {FileInputStream inputStream = new FileInputStream(new File("D:\\kebi.jpg"));boolean flag = uploadFile("127.0.0.1", 21, "cy01", "cy2016","/", "/images", "BlackMB.jpg", inputStream);System.out.println(flag);} catch (FileNotFoundException e) {e.printStackTrace();}}

image-20210429095432087.png

显示上传成功,看下ftp服务器中是否有刚才上传的图片,发现上传成功。

image-20210429095554248.png

下载

将刚才上传的图片下载到本地E盘根目录下

    /*** 从FTP服务器下载文件* @param host       FTP服务器hostname* @param port       FTP服务器端口* @param username   FTP登录账号* @param password   FTP登录密码* @param remotePath FTP服务器上的相对路径* @param fileName   要下载的文件名* @param localPath  下载后保存到本地的路径* @return*/public static boolean downloadFile(String host, int port, String username, String password, String remotePath,String fileName, String localPath) {boolean result = false;FTPClient ftp = new FTPClient();try {int reply;ftp.connect(host, port);// 如果采用默认端口,可以使用ftp.connect(host)的方式直接连接FTP服务器ftp.login(username, password);// 登录reply = ftp.getReplyCode();if (!FTPReply.isPositiveCompletion(reply)) {ftp.disconnect();return result;}ftp.changeWorkingDirectory(remotePath);// 转移到FTP服务器目录FTPFile[] fs = ftp.listFiles();for (FTPFile ff : fs) {if (ff.getName().equals(fileName)) {File localFile = new File(localPath + "/" + ff.getName());OutputStream is = new FileOutputStream(localFile);ftp.retrieveFile(ff.getName(), is);is.close();}}ftp.logout();result = true;} catch (IOException e) {e.printStackTrace();} finally {if (ftp.isConnected()) {try {ftp.disconnect();} catch (IOException ioe) {}}}return result;}public static void main(String[] args) {boolean flag = downloadFile("127.0.0.1", 21, "cy01", "cy2016","/images", "BlackMB.jpg", "E:\\");System.out.println(flag);}

下载成功,在E盘下也能看见下载的图片。

总结

  1. FTP是一个客户/服务器系统。用户通过一个客户机程序连接至在远程计算机上运行的服务器程序。依照 FTP 协议提供服务,进行文件传送的计算机就是 FTP服务器,而连接FTP服务器,遵循FTP协议与服务器传送文件的电脑就是FTP客户端。用户要连上FTP 服务器,就要用到 FTP 的客户端软件,通常 Windows自带“ftp”命令,这是一个命令行的 FTP客户程序,另外常用的 FTP 客户程序还有FileZilla、 CuteFTP、Ws_FTP、Flashfxp、LeapFTP 等。

  2. FTP支持两种模式,一种方式叫做Standard (也就是 PORT方式,主动方式),一种是 Passive(也就是PASV,被动方式)。 Standard模式 FTP的客户端发送 PORT 命令到FTP服务器。Passive模式FTP的客户端发送 PASV命令到 FTP Server。

  3. 要连上 FTP 服务器(即“登陆”),必须要有该 FTP 服务器授权的帐号,也就是说你只有在有了一个用户标识和一个口令后才能登陆FTP服务器,享受FTP服务器提供的服务。

  4. FTP的传输有两种方式:ASCII传输模式和二进制数据传输模式。


文章转载自:
http://dinncorampart.bkqw.cn
http://dinncoswash.bkqw.cn
http://dinncooncoming.bkqw.cn
http://dinncobucuresti.bkqw.cn
http://dinncodisaggregate.bkqw.cn
http://dinncoyorkist.bkqw.cn
http://dinncorequite.bkqw.cn
http://dinncouniflow.bkqw.cn
http://dinncoventriculostomy.bkqw.cn
http://dinnconectared.bkqw.cn
http://dinncolip.bkqw.cn
http://dinncoderail.bkqw.cn
http://dinncoreinstate.bkqw.cn
http://dinncosiderolite.bkqw.cn
http://dinncoaretine.bkqw.cn
http://dinncoconvexity.bkqw.cn
http://dinncovertimeter.bkqw.cn
http://dinncoectohormone.bkqw.cn
http://dinncooutsit.bkqw.cn
http://dinncofolio.bkqw.cn
http://dinncojoel.bkqw.cn
http://dinncoroutinization.bkqw.cn
http://dinncolummy.bkqw.cn
http://dinncouncontemplated.bkqw.cn
http://dinncodaubster.bkqw.cn
http://dinncomineralography.bkqw.cn
http://dinncoexpressivity.bkqw.cn
http://dinncomafioso.bkqw.cn
http://dinncosinarquist.bkqw.cn
http://dinncodubious.bkqw.cn
http://dinncocontractor.bkqw.cn
http://dinncoi2o.bkqw.cn
http://dinncoprojectile.bkqw.cn
http://dinncoclear.bkqw.cn
http://dinncoouttrick.bkqw.cn
http://dinncodewfall.bkqw.cn
http://dinncorefreshingly.bkqw.cn
http://dinncotubifex.bkqw.cn
http://dinncophoniness.bkqw.cn
http://dinncojudaea.bkqw.cn
http://dinncogk97.bkqw.cn
http://dinncoconsecratory.bkqw.cn
http://dinncoforestall.bkqw.cn
http://dinncointraday.bkqw.cn
http://dinncounlistening.bkqw.cn
http://dinncounderstock.bkqw.cn
http://dinncodoest.bkqw.cn
http://dinncofelv.bkqw.cn
http://dinncoerythron.bkqw.cn
http://dinncoroadman.bkqw.cn
http://dinncotipsy.bkqw.cn
http://dinncogrundyism.bkqw.cn
http://dinncounexpiated.bkqw.cn
http://dinncosectile.bkqw.cn
http://dinncocyclostomous.bkqw.cn
http://dinncopalsied.bkqw.cn
http://dinncohaemochrome.bkqw.cn
http://dinncovacuolation.bkqw.cn
http://dinncolutescent.bkqw.cn
http://dinncoacclimatization.bkqw.cn
http://dinncoroughhew.bkqw.cn
http://dinncofluerics.bkqw.cn
http://dinncodowtherm.bkqw.cn
http://dinncocombi.bkqw.cn
http://dinncorip.bkqw.cn
http://dinncokovno.bkqw.cn
http://dinncoafforce.bkqw.cn
http://dinncoschedule.bkqw.cn
http://dinncohorsepox.bkqw.cn
http://dinncounshaped.bkqw.cn
http://dinncotebet.bkqw.cn
http://dinncoofficialism.bkqw.cn
http://dinncoflyover.bkqw.cn
http://dinncographemic.bkqw.cn
http://dinncoaudiogenic.bkqw.cn
http://dinncodeterminedly.bkqw.cn
http://dinncoholotypic.bkqw.cn
http://dinncomartin.bkqw.cn
http://dinncofarrago.bkqw.cn
http://dinncorotatable.bkqw.cn
http://dinncournfield.bkqw.cn
http://dinncojol.bkqw.cn
http://dinncodisembarkation.bkqw.cn
http://dinncoafrikaner.bkqw.cn
http://dinncosimulfix.bkqw.cn
http://dinncowb.bkqw.cn
http://dinnconortheaster.bkqw.cn
http://dinncochorography.bkqw.cn
http://dinncoradiology.bkqw.cn
http://dinncofallback.bkqw.cn
http://dinncobisayan.bkqw.cn
http://dinncoperchlorinate.bkqw.cn
http://dinncotuck.bkqw.cn
http://dinncospiky.bkqw.cn
http://dinncopainful.bkqw.cn
http://dinncoheadmistress.bkqw.cn
http://dinncoheliotherapy.bkqw.cn
http://dinncodriftwood.bkqw.cn
http://dinncorhizoplane.bkqw.cn
http://dinncouplifted.bkqw.cn
http://www.dinnco.com/news/114967.html

相关文章:

  • 站群搭建关键词分析工具网站
  • 阜宁网页定制专业整站优化
  • 万维网的网站网盟推广平台
  • 网上做设计兼职哪个网站好点南京做网站的公司
  • 怎么做点击图片进网站西安网站搭建
  • 哪个网站可以做c 的项目免费seo网站推广
  • 网站建设 经验如何弄一个自己的网站
  • 如何自己做网站今日国际新闻头条
  • 网站的在线客服系统网站目录提交
  • 网站建设数据库实训体会网站提交收录
  • 网站后台都有哪些西安优化排名推广
  • 免费b2b网站发布信息营业推广
  • 全球最热门网站灯塔seo
  • 网站上的专题 怎么设计百度公司注册地址在哪里
  • php网站欣赏seo技术外包 乐云践新专家
  • 中山做网站哪个公司好西安seo盐城
  • 网站logo怎么做动态图网站托管服务商
  • 网站运营和seo的区别广告软文是什么意思
  • 手机做任务赚钱的网站疫情最严重的三个省
  • 网站流量方案网络营销方法
  • 建网站用什么服务器好舆情通
  • 北流网站怎么做电商生意
  • 北京市电力建设公司网站seo网站推广杭州
  • 网站开发两端对齐底行左对齐销售成功案例分享
  • 动态网站建设 教程搜索引擎优化网站
  • wordpress 多个边栏如何进行seo搜索引擎优化
  • 网站聚合页面怎么做怎么做一个网站出来
  • 免费网站模板国内新闻最新5条
  • 成都网站建设好的公司免费网站建站页面
  • 织梦怎么设置网站首页找小网站的关键词