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

关于图片上传的问题
我想将本地硬盘上的图片上传到服务器啊,我实现的代码是:
string   pathname   =   System.DateTime.Now.ToShortDateString();
string   path1   =   "UploadFiles/ "   +   pathname   +   " ";
string   fullPath   =   Server.MapPath( "../Html/ ")   +   pathname+ "\\ ";
if   (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(fullPath);
}
string   fullname=this.inpFileUp.PostedFile.FileName;
string   filename   =   fullname.Substring(fullname.LastIndexOf( "\\ ")   +   1);
string   type   =   fullname.Substring(fullname.LastIndexOf( ". ")+1);
if   (type   ==   "jpg "   ||   type   ==   "gif "   ||   type   ==   "bmp ")
{
this.inpFileUp.PostedFile.SaveAs(fullPath   +   filename);
this.Photo_Path.Text=fullPath   +   filename;
}
else
{
Response.Write( " <script   language= 'java-script '> alert( '你上传的文件格式不正确! ') </script> ");
}

然后把图片的路径保存到了数据库中,通过Image的Url来链接图片的地址

我可以到虚拟目录下面看已经有图片上传到了文件夹里面去了,我自己本身浏览主页的时候可以看到图片,可以我在别人的电话上访问主页时,就不能看到图片,但Url路径是正确的.

这个问题怎么解决   ?????

------解决方案--------------------
改成this.Image5.ImageUrl= this.ResolveUrl(myds.Tables[ "ProductsList "].Rows[0][ "Image "].ToString());试试
------解决方案--------------------
file:///c:/inetpub/wwwroot/HNYPGX/Html/2007-8-23/LoginBack.jpg
我在别人的电话上看到的路径也是
file:///c:/inetpub/wwwroot/HNYPGX/Html/2007-8-23/LoginBack.jpg

都得到这样路径了,还用什么方法啊,晕

一定要用相对路径.这哥们没搞清这个,必须搞清这个,自己想吧