首页上一页 1 下一页尾页 1 条记录 1/1页
如何在远程应用服务器端获取图片的宽度和高度?
发表在ASP.NET图书答疑
2008-11-19
是否精华
是
否
版块置顶:
是
否
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
public int width, height; //定义全局变量
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_ServerClick(object sender, EventArgs e)
{
if (this.FileUpload1.PostedFile.FileName != null)
{
string path = this.FileUpload1.PostedFile.FileName;
System.Net.FileWebRequest q = (System.Net.FileWebRequest)System.Net.FileWebRequest.Create(path);
System.Net.FileWebResponse p = (System.Net.FileWebResponse)q.GetResponse();
System.Drawing.Image bmp = System.Drawing.Image.FromStream(p.GetResponseStream());
string ss = path.Substring(path.LastIndexOf("\\") + 1);
string s = Server.MapPath("Images\\" + ss);
string imgpath = "Images\\" + ss;
this.FileUpload1.PostedFile.SaveAs(s);
this.Image1.ImageUrl = imgpath;
width = bmp.Width;
height= bmp.Height;
}
}
}
此程序在本地服务器可获得上传图片的高度和宽度,但在远程应用服务器端却获取不到图片的高度和宽度,请高手指明是服务器的配置问题还是程序问题?
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
public int width, height; //定义全局变量
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_ServerClick(object sender, EventArgs e)
{
if (this.FileUpload1.PostedFile.FileName != null)
{
string path = this.FileUpload1.PostedFile.FileName;
System.Net.FileWebRequest q = (System.Net.FileWebRequest)System.Net.FileWebRequest.Create(path);
System.Net.FileWebResponse p = (System.Net.FileWebResponse)q.GetResponse();
System.Drawing.Image bmp = System.Drawing.Image.FromStream(p.GetResponseStream());
string ss = path.Substring(path.LastIndexOf("\\") + 1);
string s = Server.MapPath("Images\\" + ss);
string imgpath = "Images\\" + ss;
this.FileUpload1.PostedFile.SaveAs(s);
this.Image1.ImageUrl = imgpath;
width = bmp.Width;
height= bmp.Height;
}
}
}
此程序在本地服务器可获得上传图片的高度和宽度,但在远程应用服务器端却获取不到图片的高度和宽度,请高手指明是服务器的配置问题还是程序问题?