Welcome Guest Search | Active Topics | Members

Custom File Restriction (Image Dimension Aspect Ratio) Options
Fedor
Posted: Friday, April 07, 2006 8:01:26 AM

Rank: Advanced Member
Groups: Administration , Member

Joined: 7/28/2003
Posts: 1,254
Points: -345
Location: WA, US
Hello,

I just wanted to post simple code snippet how to add custom file restriction. For example you can allow to select images with 3:4 aspect ratio only:

Code:
<script language="javascript" src="iuembed.js"></script>

<script language="javascript">
function ImageUploader_UploadFileCountChange(){
    var imageUploader=getImageUploader("ImageUploader");
    for (i=imageUploader.UploadItems.Count; i>=1; i--){
        var uploadItem = imageUploader.UploadItems.Item( i)
        if (uploadItem.Height/uploadItem.Width!=0.75){
            alert(uploadItem.FileName + " doesn't have 3:4 ratio.");
            imageUploader.UploadItems.Remove(i);
        }
    }
}
</script>

<script language="javascript">
var iu = new ImageUploaderWriter("ImageUploader", 770, 500);


//For ActiveX control we specify full path for CAB file
iu.activeXControlCodeBase = "./ImageUploader3.cab";
iu.activeXControlVersion = "3,5,204,0";

//For Java applet we specify only directory with JAR files
iu.javaAppletCodeBase = "./";
iu.javaAppletCached = true;
iu.javaAppletVersion = "1.1.81.0";

iu.addParam("Layout","TwoPanes");
iu.addParam("Action","Upload.aspx")

iu.addEventListener("UploadFileCountChange", "ImageUploader_UploadFileCountChange");

iu.writeHtml();
</script>


Best regards,
Fedor Skvortsov
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.