本文介绍了在asp.net上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName))

这适用于localhost但不能在服务器上运行。文件未在服务器上保存

FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName))
this works fine with localhost but not working on server. file not saving on server

推荐答案

FileUpload1.PostedFile.SaveAs(Server.MapPath(FileUpload1.FileName)) 











or

FileUpload1.PostedFile.SaveAs(Server.MapPath(@"~\UploadDocumnets\"+FileUpload1.FileName)) 


//Get Filename from fileupload control
                string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
                //Save images into Images folder
                FileUpload1.SaveAs(Server.MapPath("~/Images/" + filename));



谢谢你。


Thank u.


这篇关于在asp.net上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 22:56