在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<%@ WebHandler Language="C#" Class="UploadHandler" %> using System; using System.IO; using System.Web; using System.Data.SqlClient; public class UploadHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Charset = "utf-8"; HttpPostedFile file = context.Request.Files["Filedata"]; string fileName=file.FileName; string extensionName = fileName.Substring(fileName.LastIndexOf('.')); string reFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string folder = @context.Request["folder"]; string uploadPath = HttpContext.Current.Server.MapPath(folder) + "\\"; if (file != null) { if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } file.SaveAs(uploadPath + reFileName + extensionName); DBUtility.DbHelperSQL.ExecuteSql("insert into ok_docs_file(docs02,docs03,docs04) values(@docs02,@docs03,getdate())", new SqlParameter("@docs02", fileName), new SqlParameter("@docs03", folder + "/" + reFileName + ".swf")); //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失 ConvertToSWF(uploadPath + reFileName + extensionName, uploadPath+ reFileName + ".swf"); context.Response.Write("1"); } else { context.Response.Write("0"); } } public void ConvertToSWF(string oldFile, string swfFile) { System.Diagnostics.Process pc = new System.Diagnostics.Process(); pc.StartInfo.FileName = @"E:\oaoffice\Web\FlashPaper2.2\FlashPrinter.exe";//安装路径 pc.StartInfo.Arguments = string.Format("{0} -o {1}", oldFile, swfFile); pc.StartInfo.CreateNoWindow = true; pc.StartInfo.UseShellExecute = false; pc.StartInfo.RedirectStandardInput = false; pc.StartInfo.RedirectStandardOutput = false; pc.StartInfo.RedirectStandardError = true; pc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; pc.Start(); pc.WaitForExit(); pc.Close(); pc.Dispose(); } public bool IsReusable { get { return false; } } } 源码下载:http://pan.baidu.com/share/link?shareid=2513136070&uk=3289148388 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论