【问题标题】:Server code to accept file uploaded from intel XDK接受从英特尔 XDK 上传的文件的服务器代码
【发布时间】:2014-05-13 08:45:11
【问题描述】:

目前我正在创建一个使用 IntelXDK 将图像从设备上传到我的服务器的应用程序。 我目前遇到的问题是,如何对我的后端进行编码,以便它可以接收来自移动设备的上传文件?

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

  1. 然后使用 $FILES["file"] 将其保存到存储中

在 .Net 中也几乎相似。 但是我仍然想不出通过手机上传文件后如何接收文件。 如果有人分享或建议缺少的部分(.Net 和 PHP),那就太好了。

【问题讨论】:

    标签: php .net intel-xdk


    【解决方案1】:

    在 ASP.net 服务器端使用 webservice 以字节格式接收并根据需要保存。

    代码示例参考链接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();
            }
        }
    }
    

    }

    【讨论】:

      【解决方案2】:

      有关将文件上传到服务器的更多信息:https://software.intel.com/en-us/node/493213

      【讨论】:

      • 我在问服务器代码会是什么样子。干杯^^
      【解决方案3】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多