在Android上上传​​图片与FTP [英] Uploading images with FTP on Android

查看:171
本文介绍了在Android上上传​​图片与FTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用FTP上传影像在Android?

How can I upload images using FTP on Android?

推荐答案

使用SimpleFTP,只需添加simpleftp.jar到类路径,并导入在哪个班会使用它的包:的Download这里

Use SimpleFTP, simply add simpleftp.jar to your classpath and import the package in whichever classes will use it: Download here

import org.jibble.simpleftp.*;

请确保您使用二进制模式上传图像和类似的东西的时候,也可能会损坏。

Make sure you use binary mode when uploading images and suchlike, or they may become corrupted.

try
{
    SimpleFTP ftp = new SimpleFTP();

    // Connect to an FTP server on port 21.
    ftp.connect("ftp.somewhere.net", 21, "username", "password");

    // Set binary mode.
    ftp.bin();

    // Change to a new working directory on the FTP server.
    ftp.cwd("web");

    // Upload some files.
    ftp.stor(new File("webcam.jpg"));
    ftp.stor(new File("comicbot-latest.png"));

    // You can also upload from an InputStream, e.g.
    ftp.stor(new FileInputStream(new File("test.png")), "test.png");
    ftp.stor(someSocket.getInputStream(), "blah.dat");

    // Quit from the FTP server.
    ftp.disconnect();
}
catch (IOException e)
{
    e.printStackTrace();
}

这是所有的功能,所以它不会让你下载的文件!

This was all the functionality, so it does not let you download files!

这篇关于在Android上上传​​图片与FTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆