Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Asp.net中上传照片并保存其纵横比_Asp.net_Css_Visual Studio 2010 - Fatal编程技术网

如何在Asp.net中上传照片并保存其纵横比

如何在Asp.net中上传照片并保存其纵横比,asp.net,css,visual-studio-2010,Asp.net,Css,Visual Studio 2010,我的网站的用户使用HTML输入(文件)上传照片,如下所示: Fname = File1.PostedFile.FileName.ToString(); int Index = Fname.LastIndexOf("\\"); Fname = Fname.Substring(Index + 1); string Fname1 = MapPath(Fname); File1.PostedFile.SaveAs(Fname1); img =File1.AppRelativeTemplateSource

我的网站的用户使用HTML输入(文件)上传照片,如下所示:

Fname = File1.PostedFile.FileName.ToString();
int Index = Fname.LastIndexOf("\\");
Fname = Fname.Substring(Index + 1);
string Fname1 = MapPath(Fname);
File1.PostedFile.SaveAs(Fname1);
img =File1.AppRelativeTemplateSourceDirectory+ Fname;
Image1.ImageUrl = img;

Image1的大小是100*200,但我想保存像100*[(h/w)*100]这样的图像。如何保存此图像?

在保存图像之前,必须调整图像大小。检查示例

链接不正确。请解释更多首先您必须从发布的文件中获取流,如下所示:stream inputStream=File1.PostedFile.inputStream;然后使用方法ResizeFromStreamfromExample链接,当然您需要在示例中更改newWidth的值