如何在uploadnig之前检查图像的大小? [英] How can I check the size of the images before uploadnig ?
本文介绍了如何在uploadnig之前检查图像的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hii朋友,
我正在开发asp.net项目。我在这里查询。
在我的应用程序中我在母版页上需要动态徽标。如何在上传时检查图像的大小?如果我点击上传徽标,那么在上传之前必须检查尺寸[宽度:250px,高度:65px],如果没有则我该怎么收缩呢?
请帮帮我。谢谢。
Hii friends,
I am working on asp.net project.and i stuck here with query.
In my application i need dynamic logo on master page..How can I check the size of the images while uploading?That is if i am clicking on upload logo then it must check for size [width:250px,height:65px] before uploading and if not then how can i shrink it?
Please help me.Thanks in advance.
推荐答案
当你尝试上传你的图像时,猜猜你会有一个按钮。
那么,在这种情况下写一个JavaScript函数来获得高度图片的宽度和宽度。
如果高度和宽度与尺寸不符,请使用一些JavaScript材料改变高度/宽度。
以下代码段可能对您有所帮助:
Hi,
Guess you would have a button when you try to upload your image.
Well, in that case write a JavaScript function to get the height and width of the image.
If the height and width don't match your dimensions, alter the height/width using some JavaScript stuffs.
Below snippet might help you:
var x=document.getElementByID('imageId');
function getDimensions()
{
var height=x.ClientHeight;
var width=x.ClientWidth;
if(height!=defaultHeight && width!=defaultWidth)
{
window.alert('Dimensions aint correct, calling CorrectDimensions method');
CorrectDimensions();
}
else
}
function CorrectDimensions()
{
x.ClientHeight=100px;
x.ClientWidth=100px;
}
上面的代码片段并不完美,但是应该让你开始并提供帮助方式。
-Anurag
The above snippet won't be perfect, but should get you started and help along the way.
-Anurag
您好Aysha Patel
请参阅本教程。
http:// tech.pro/tutorial/620/csharp-tutorial-image-editing-saving-cropping-and-resizing [ ^ ]
Hi Aysha Patel
See this tutorial.
http://tech.pro/tutorial/620/csharp-tutorial-image-editing-saving-cropping-and-resizing[^]
这篇关于如何在uploadnig之前检查图像的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文