多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
C#代码示例 ```C# //文件名:upload.ashx <%@ WebHandler Language="C#" Class="upload" %> using System; using System.Web; public class upload : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Charset = "utf-8"; var files = context.Request.Files; if (files.Count <= 0) { return; } HttpPostedFile file = files[0]; if (file == null) { context.Response.Write("file is null"); return; } else { string path = context.Server.MapPath("~/uploadedFiles/"); //存储图片的文件夹 string originalFileName = file.FileName; string fileExtension = originalFileName.Substring(originalFileName.LastIndexOf('.'), originalFileName.Length - originalFileName.LastIndexOf('.')); string currentFileName = (new Random()).Next() + fileExtension; //文件名中不要带中文,否则会出错 //生成文件路径 string imagePath = path + currentFileName; //保存文件 file.SaveAs(imagePath); //获取图片url地址 string imgUrl = "http://localhost:8888/uploadedFiles/" + currentFileName; //返回图片url地址 context.Response.Write(imgUrl); return; } } public bool IsReusable { get { return false; } } } ```