您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > aspxuploadcontrol文件上传技术文档
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingDevExpress.Web.ASPxUploadControl;usingSystem.IO;usingMicrosoft.Office.Interop.Word;usingMS.Internal.Xml;usingWord=Microsoft.Office.Interop.Word;publicpartialclassContributor_Author_Upload:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}//protectedvoidbtnUpload_Click(objectsender,EventArgse)//{//stringid=Session[稿?件tID].ToString();//Session[稿?件tID].ToString();//stringzzlb=Request.QueryString[zzlb];//stringny=Request.QueryString[ny];//stringbc=Request.QueryString[bc];//stringgjbt=Request.QueryString[gjbt];//decimalfilesize=FileUpload_upload.PostedFile.ContentLength/1024;//stringfiletype=FileUpload_upload.PostedFile.ContentType;//if(this.FileUpload_upload.PostedFile.FileName==)//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,请?选?择?文?件t!));//return;//}//if(this.FileUpload_upload.FileName.Substring(this.FileUpload_upload.FileName.Length-4,4).ToLower()!=.doc)//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,请?上¦?传ä?Doc文?件t!));//return;//}//if(filesize/10241)//限T制?为a1M//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,文?件t不?能¨¹超?过y2M));//return;//}//try//{//stringClientPath=FileUpload_upload.PostedFile.FileName;//客¨ª户¡ì端?文?件t路¡¤径?//FileInfoClientPathFile=newFileInfo(ClientPath);//stringServerPath=C:\\+zzlb+\\+ny+\\+bc;//Server.MapPath(../Document/稿?件tword/+id+_+ClientPathFile.Name);//服¤t务?端?文?件t路¡¤径?//stringFileName=FileUpload_upload.FileName;////判D断?是º?否¤?存ä?在¨²文?件t夹D,ê?不?存ä?在¨²则¨°创ä¡ä建¡§//DirectoryInfofile=newDirectoryInfo(ServerPath);//if(!file.Exists)//{//file.Create();//}//ServerPath=ServerPath+\\+id+_+gjbt+.doc;////if(System.IO.File.Exists(ServerPath))//判D断?服¤t务?器¡Â上¦?是º?否¤?有®D同ª?名?文?件t存ä?在¨²,ê?若¨?自Á?己o定¡§义°?名?称?可¨¦上¦?传ä?////{////ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,重?复¡ä文?件t名?称?!));////return;////}//this.FileUpload_upload.SaveAs(ServerPath);//保À¡ê存ä?文?件t//DataSet_GJXXTableAdapters.TA_MANUSCRIPTTableAdapterta=newDataSet_GJXXTableAdapters.TA_MANUSCRIPTTableAdapter();//ta.UpdateQuery_原-稿?文?件t(ServerPath,getWordsNumber(ServerPath),id);//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,上¦?传ä?成¨¦功|!ê?));//}//catch(Exception)//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,发¤¡é生¦¨²异°¨¬常¡ê,ê?请?重?新?上¦?传ä?!));//}//}/***2013/11/22*徐¨¬昌y*/protectedvoidASPxUploadControl1_FileUploadComplete(objectsender,FileUploadCompleteEventArgse){stringid=Session[稿?件tID].ToString();//Session[稿?件tID].ToString();stringzzlb=Request.QueryString[zzlb];stringny=Request.QueryString[ny];stringbc=Request.QueryString[bc];stringgjbt=Request.QueryString[gjbt];stringname=Request.QueryString[name].ToString();//if(this.ASPxUploadControl1.PostedFile.FileName==)//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,请?选?择?文?件t!));//return;//}//if(this.ASPxUploadControl1.FileName.Substring(this.FileUpload_upload.FileName.Length-4,4).ToLower()!=.doc)//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,请?上¦?传ä?Doc文?件t!));//return;//}try{//stringClientPath=FileUpload_upload.PostedFile.FileName;//客¨ª户¡ì端?文?件t路¡¤径?//FileInfoClientPathFile=newFileInfo(ClientPath);stringPath=C:\\+zzlb+\\+ny+\\+bc;//Server.MapPath(../Document/稿?件tword/+id+_+ClientPathFile.Name);//服¤t务?端?文?件t路¡¤径?//stringFileName=FileUpload_upload.FileName;//判D断?是º?否¤?存ä?在¨²文?件t夹D,ê?不?存ä?在¨²则¨°创ä¡ä建¡§DirectoryInfofile=newDirectoryInfo(Path);if(!file.Exists){file.Create();}stringServerPath=Path+\\+id+_+gjbt+.doc;stringfilepath=id+_+gjbt+.doc;//if(Directory.Exists(Path))//{//foreach(stringdinDirectory.GetFileSystemEntries(Path))//{//if(d.Equals(filepath))//{//file.Delete(true);//}//}//}//if(System.IO.File.Exists(ServerPath))//判D断?服¤t务?器¡Â上¦?是º?否¤?有®D同ª?名?文?件t存ä?在¨²,ê?若¨?自Á?己o定¡§义°?名?称?可¨¦上¦?传ä?//{//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,重?复¡ä文?件t名?称?!));//file.Delete();//}//stringfilename=ServerPath+e.UploadedFile.FileName;this.ASPxUploadControl1.SaveAs(ServerPath);//this.FileUpload_upload.SaveAs(ServerPath);//保À¡ê存ä?文?件t//System.DateTimecurrentTime=newSystem.DateTime();//stringstrMD=currentTime.ToString(m);DataSet_GJXXTableAdapters.TA_MANUSCRIPTTableAdapterta=newDataSet_GJXXTableAdapters.TA_MANUSCRIPTTableAdapter();ta.UpdateQuery_原-稿?文?件t(ServerPath,getWordsNumber(ServerPath),name,DateTime.Now.Date,id);//ta.UpdateQuery_原-稿?文?件t(ServerPath,getWordsNumber(ServerPath),id);//ClientScript.RegisterStartupScript(this.GetType(),alert,String.Format(scriptalert('{0}');/script,上¦?传ä?成¨¦功|!ê?));//Response.Write(string.Format(scriptalert('提¬¨¢交?成¨¦功|!ê?');
本文标题:aspxuploadcontrol文件上传技术文档
链接地址:https://www.777doc.com/doc-2898820 .html