如何将图像文件阵列发送到Windows服务器

时间:2013-02-18 15:46:04

标签: cordova jquery-mobile send

我使用jquery mobile和PhoneGap。

我有几个图像文件,我想发送到目录中的服务器

我的照片存储在我的手机上

2 个答案:

答案 0 :(得分:0)

使用您喜欢的技术创建Web服务,在服务器上授予写入权限,然后为每个图像文件让您的PhoneGap应用程序将图像字节发送到服务器,以及文件名和所有者等元数据。 / p>

答案 1 :(得分:0)

FileTransfer是一个对象,允许您将文件上传到服务器或从服务器下载文件,它包含在Apache Cordova API Reference中。在我看来,使用FileTransfer对象是将文件上传到远程服务器的正确方法。

如果检查Apache Cordova jar中的FileTransfer类的实现,您将看到上传方法的签名是:

    /**
     * Uploads the specified file to the server URL provided using an HTTP multipart request.
     * @param source        Full path of the file on the file system
     * @param target        URL of the server to receive the file
     * @param args          JSON Array of args
     * @param callbackContext    callback id for optional progress reports
     *
     * args[2] fileKey       Name of file request parameter
     * args[3] fileName      File name to be used on server
     * args[4] mimeType      Describes file content type
     * args[5] params        key:value pairs of user-defined parameters
     * @return FileUploadResult containing result of upload request
     */
    private void upload(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException {

这意味着该方法希望接收第一个参数,即单个源字符串(表示文件系统上文件的完整路径),而不是字符串数组。

因此,如果您选择继续使用FileTransfer选项,则可能无法进行多个FileTransfer上传调用。