【发布时间】:2012-02-26 03:38:04
【问题描述】:
我目前正在使用 Redfoundry.com 框架 (RFML) 构建照片上传应用程序。他们给了我一个后端应该是什么样子的例子,不幸的是在.Net中
甚至可以将这段代码转换为 PHP 吗?感谢您的帮助
编辑:格式为.jpg
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace MYNamespace
{
public class api : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string res = "";
if (context.Request.Files != null)
{
if (context.Request.Files.Count > 0)
{
HttpPostedFile oHttpPostedFile = context.Request.Files[0];
if (oHttpPostedFile != null)
{
if (oHttpPostedFile.ContentLength > 0)
{
oHttpPostedFile.SaveAs(System.IO.Path.Combine(System.Web.HttpContext.Current.Request.MapPath(@"PHOTOS"), guid + ".jpg"));
res = "<results>SUCCESS</results>";
}
}
}
}
context.Response.ContentType = "text/xml";
context.Response.Write((res.length == 0 ? "<results>FAILED</results>" : res))
}
}
}
【问题讨论】:
-
是的,有可能。我建议您尝试一下,如果遇到问题,请回到这里寻求帮助。您可以在 Internet 上找到许多 PHP 教程。