DOS上传文件到服务器

起因:笔者想将本地文件上传到服务器上

(1)在服务器上安装vsftpd,这里不再赘述了

(2)在Dos中输入以下命令,然后再输入用户名和密码

ftp xxx.xxx.xxx.xxx

(3)然后就出现问题了,可以连接上,但是无法使用相关命令

网上有各种各样的方法,啥主动模式被动模式的,大致尝试了一下没能解决,呜呜呜~

(4) 然后我想起来之前使用Xshell连接成功过centos时好像使用的sftp,然后将ftp换成sftp,成功!奈斯

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,关于android上传视频到服务器的代码实现,以下是一个简单的示例: 1. 在android应用中,首先需要选择一个视频文件并打开它,可以使用Android Intent来实现: ``` Intent intent = new Intent(); intent.setType("video/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select a Video "), SELECT_VIDEO); ``` 2. 选择完视频文件后,就需要将其上传到服务器了,可以使用HTTPURLConnection来进行上传: ``` public int uploadVideo(String sourceFileUri) { String upLoadServerUri = "http://example.com/your_php_script.php"; String fileName = sourceFileUri; HttpURLConnection conn = null; DataOutputStream dos = null; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int serverResponseCode = 0; try { FileInputStream fileInputStream = new FileInputStream(new File(sourceFileUri)); URL url = new URL(upLoadServerUri); conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("ENCTYPE", "multipart/form-data"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); conn.setRequestProperty("uploaded_file", fileName); dos = new DataOutputStream(conn.getOutputStream()); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";filename=\"" + fileName + "\"" + lineEnd); dos.writeBytes(lineEnd); byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = fileInputStream.read(buffer)) > 0) { dos.write(buffer, 0, bytesRead); } dos.writeBytes(lineEnd); dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); serverResponseCode = conn.getResponseCode(); String serverResponseMessage = conn.getResponseMessage(); fileInputStream.close(); dos.flush(); dos.close(); } catch (Exception e) { e.printStackTrace(); } return serverResponseCode; } ``` 这段代码将视频文件通过HTTP POST请求上传到服务器上,需要替换upLoadServerUri为你的服务器地址,同时还需要在你的服务器上编写相应的PHP脚本,来处理上传的视频。 希望这个简单示例能够帮助到你,如果还有什么问题,请随时提出。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值