服务器code接受来自英特尔XDK上传文件 [英] Server code to accept file uploaded from intel XDK

查看:108
本文介绍了服务器code接受来自英特尔XDK上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我创建使用IntelXDK从设备的图像上传到我的服务器上的应用程序。 目前我遇到的问题是,如何为$ C C我的后端$,以便它可以接收来自移动设备上传文件?

Currently I'm creating an app using IntelXDK to upload image from devices to my server. The problem currently I'm encountering is, how to code my backend so that it can receive the upload file from mobile device?

在PHP中,我只知道文件上传要求:

In PHP, I only know that the file upload requires:

  1. <输入类型=文件名称=文件/>
  2. 然后使用$文件[档案]将其保存到存储

和是.NET几乎相同为好。 但我还是想不出如何接收该文件一旦通过手机上传。 将是巨大的,如果有人共享或告知缺失的部分(.Net和PHP)。

And is almost similar in .Net as well. But I'm still couldn't think of how to receive the file once it is uploaded via mobile. Would be great if someone share or advise the missing part (.Net and PHP).

推荐答案

在ASP.net服务器端使用web服务接收字节格式并保存为你想要的。

In ASP.net server side use webservice receive in byte format and save that as you want.

code样品refrence链接的http://www.$c$cproject.com/Articles/22985/Upload-Any-File-Type-through-a-Web-Service

Code sample refrence link http://www.codeproject.com/Articles/22985/Upload-Any-File-Type-through-a-Web-Service

[WebMethod的]

[WebMethod]

    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();
        }
    }
}

}

这篇关于服务器code接受来自英特尔XDK上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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