0

現在、IntelXDK を使用してデバイスからサーバーに画像をアップロードするアプリを作成しています。現在私が直面している問題は、モバイル デバイスからアップロード ファイルを受信できるようにバックエンドをコーディングする方法です。

PHP では、ファイルのアップロードに次のものが必要であることしか知りません。

  1. <input type="ファイル" name="ファイル" />
  2. 次に、$FILES["file"] を使用してストレージに保存します

.Net でもほぼ同様です。しかし、モバイル経由でアップロードされたファイルを受信する方法はまだ考えられません。不足している部分 (.Net および PHP) を誰かが共有またはアドバイスしてくれれば幸いです。

4

3 に答える 3

0

ASP.net サーバー側では、webservice receive をバイト形式で使用し、必要に応じて保存します。

コード サンプル参照リンクhttp://www.codeproject.com/Articles/22985/Upload-Any-File-Type-through-a-Web-Service

【ウェブメソッド】

    public string UploadFile(byte[] f, string fileName)
    {
        // the byte array argument contains the content of the file
        // the string argument contains the name and extension
        // of the file passed in the byte array
        try
        {
            // instance a memory stream and pass the
            // byte array to its constructor
            MemoryStream ms = new MemoryStream(f);

            // instance a filestream pointing to the
            // storage folder, use the original file name
            // to name the resulting file
            FileStream fs = new FileStream
                (System.Web.Hosting.HostingEnvironment.MapPath
                ("~/TransientStorage/") +
                fileName, FileMode.Create);

            // write the memory stream containing the original
            // file as a byte array to the filestream
            ms.WriteTo(fs);

            // clean up
            ms.Close();
            fs.Close();
            fs.Dispose();

            // return OK if we made it this far
            return "OK";
        }
        catch (Exception ex)
        {
            // return the error message if the operation fails
            return ex.Message.ToString();
        }
    }
}

}

于 2014-05-13T00:45:11.657 に答える
0

サーバーへのファイルのアップロードの詳細については、https ://software.intel.com/en-us/node/493213 を参照してください。

于 2014-05-09T21:35:42.467 に答える