在上传或调整图像大小时检查图像的大小 [英] Check size of Image in the time of Uploading or resize the image

查看:90
本文介绍了在上传或调整图像大小时检查图像的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据库中上传修复图片大小。或者在上传时调整图片大小.plz帮助我

I want to upload fix Size of image in the database.or resize Image on the time of uploading.plz help me

推荐答案

尝试以下方法: - < br $> b $ b

Try the following :-

string[] sizes = { "B", "KB", "MB", "GB" };
double len = new FileInfo(filename).Length;
int order = 0;
while (len >= 1024 && order + 1 < sizes.Length) {
    order++;
    len = len/1024;
}







string result = String.Format({0:0。# #} {1},len,sizes [order]);




string result = String.Format("{0: 0.##} {1}", len, sizes[order]);


我在上传图片时对大小进行了一次验证,我使用HTTPHandler来避免回发。



但您的要求似乎有所不同,如果不是所需尺寸,您需要调整大小。你可以按照以下链接







http://stackoverflow.com/questions/254419/asp-net-image-uploading-with-resizing [ ^ ]
I implemented once validation on size while uploading the image, I used a HTTPHandler to avoid postback.

But your requirement seems different, you want to resize if it not of required size. You can follow the below link



http://stackoverflow.com/questions/254419/asp-net-image-uploading-with-resizing[^]


这篇关于在上传或调整图像大小时检查图像的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆