.NET什么控制上传图片的类型

我的是说怎样能够只有图片类型的文件类型?其他什么所有类型都没有在文件类型中显示!我是用控件FileUpload 这个的 <asp:FileUpload ID="ImgFileUp" runat="server" />
。。。。

第1个回答  2011-09-25
楼上的意思就是取你选择的文件名(.)后面的字符串,也就是去后缀名,然后根据你自己的需要判断。
第2个回答  2011-09-20
C# code
string Ex = this.PicUrl.FileName.Substring(this.PicUrl.FileName.LastIndexOf(".") + 1);

if (Ex.ToLower() == "jpg" || Ex.ToLower() == "gif")
{
if (this.PicUrl.HasFile)
{
//this.PicUrl.PostedFile.SaveAs(picPath + picName);
cn.SmallImag(this.PicUrl.PostedFile.FileName, picPath + picName);
this.Image1.ImageUrl = @"../GoodsPic/" + picName;
FullPath = @"GoodsPic/" + picName;

}
你试试吧!祝你成功!追问

cn.SmallImag(this.PicUrl.PostedFile.FileName, picPath + picName);
this.Image1.ImageUrl = @"../GoodsPic/" + picName;
FullPath = @"GoodsPic/" + picName;
这段有点不明白啊!

追答

你得试试吧,试试你才知道怎么弄!我也没具体弄过。

追问

我什么弄啊,,都不懂picName ,cn ,picPath ,GoodsPic等等这些哪里来的?

本回答被提问者采纳
相似回答
大家正在搜