JS detection upload picture type and width (scaled)
<form action= "" method= "Post" enctype= "Multipart/form-data" name= "Dform" >
<label for= "IFile" ></label>
<input type= "File" Name= "IFile" id= "IFile" >
<input type= "Submit" name= "button" id= "button" value= "Submit" onclick= "Web Effects: toi_upimg ();" >
</form>
<script>
function toi_upimg ()
{
var form = Document.dform;
var isrc = Form.ifile.value;
var pos = Isrc.lastindexof ('. ');
var img = new Image ();
//On load
img.onload = function () {
var width = img.width;
var height = img.height;
img.onload = ';
if (Width > | | height >)
{
=> 480*360
var ratio1 = 320/width;
var Ratio2 = 240/height;
if (Ratio1 > Ratio2)
{
width = parseint (Ratio2 * width);
height = 240;
}
Else
{
width = 320;
height = parseint (ratio1 * height);
}
alert (' Note: The picture is too large, the system has made some adjustments automatically ');
toi_img.src = img.src;
toi_img.width = width;
toi_img.height = height;
Form.picwidth.value = width;
Form.picheight.value = height;
Form.mserver.value = "no";
form.xpost.value = ' 0 ';
form.ypost.value = ' 0 ';
form.xposy.value = ' 0 ';
form.yposy.value = ' 0 ';
form.xposa.value = ' 0 ';
form.yposa.value = ' 0 ';
if (Form.title.value = = ")
{
var pos2 = Isrc.lastindexof (");
form.title.value = isrc.substring (Pos2+1,pos);
}
toi_update ();
delete img;
};
On Error
Img.onerror = function () {
Img.onerror = ';
Alert (' Note: A file you just tried to upload does not appear to be a legitimate picture ');
Delete img;
};
Store the source address
if (Navigator.appversion.indexof (' Msie 7 ') >= 0)
{
document.getElementById ("Filterimage"). Filters.item ("Dximagetransform.microsoft.alphaimageloader"). src = isrc;
IMG.SRC = document.getElementById ("Filterimage"). Filters.item ("Dximagetransform.microsoft.alphaimageloader"). src ;
}
Else
{
IMG.SRC = ISRC;
}
}
</script>