日期:2014-05-18  浏览次数:21017 次

求文件上传代码(vs2003的)我写的老出错。
求文件上传代码(vs2003的)我写的老出错。
谢谢。

------解决方案--------------------
小文件上传

//产生新文件名
string newFileName = ToniRoot.uploadFile.newFileName(ToniRoot.uploadFile.getExtName(ToniRoot.uploadFile.getFileName(File1.PostedFile.FileName)));
//产生新路径
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
string PhotoPath = ((string)(configurationAppSettings.GetValue( "PhotoPath ", typeof(string))));
string newFilePath = ToniRoot.uploadFile.newFilePath(PhotoPath,newFileName);
//验证新路径
if (!Directory.Exists(Server.MapPath(newFilePath)))
{
Directory.CreateDirectory(Server.MapPath(newFilePath));
}
//保存文件
File1.PostedFile.SaveAs(Server.MapPath(newFilePath+newFileName));

//File1是protected System.Web.UI.HtmlControls.HtmlInputFile File1; htmlInputfile组件


如果上传大文件请用一些文件上传组件如neatupload