[Javascript] Resizing images client-side

Troy III Ajnej trojani2000 at hotmail.com
Sat Jul 14 13:04:28 CDT 2007


[!This post never made it to LaTech, so I'm reposting it]
 



> Would love to see what you might make. Doesn't everybody, including myself, hope and expect my statementto be true to a certain extent?  I even googled a little just to find that there is no simple solution thatwill be able to validate dhe image size on the client side without serv-erside roundtrips. etc. And it's...-Sad! Right now,all I can show you is this brute prtotype of demonstration code. -Test this: <FORM name="upl" onsubmit = "" action = "" method = "post" >    <INPUT type="file" size="124"       name="filecontent"       value="" onchange="setImg()"/> </FORM>
<script>function setImg(){ imgTester.src=document.upl.filecontent.value }function validate(){ 
 alert(imgTester.fileSize)
//your condtitionals and submit decision cn go here.. }</script> <img src="" style='height:100px; width:100px; display:none'  id='imgTester'  name='imgTester'  onload='validate()' \> ***This will work on IE version browsers for sure, I leave it up to you guys 
to find the way to make it compatible with other browsers, because this
is only a demonstration of the prime idea...
 Regards.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                        Troy III                            progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



> Date: Fri, 13 Jul 2007 21:04:14 -0400> To: javascript at LaTech.edu> From: tedd at sperling.com> Subject: RE: [Javascript] Resizing images client-side> CC: trojani2000 at hotmail.com> > At 11:34 PM +0000 7/13/07, Troy III Ajnej wrote:> >Hi Paul> >> >Hahahahaa,> >If I wasn't drunked last night and didn'tmcompletely missunderstood> >the problem, I believe it is very easy to get it done via javascript.> >> >As I remember (?)Tedd asked about how to disable or prevent the> >client from uploading large pictures, suppose, not bigger than 500k.> >> >All it takes is just a little bit of imagination or creativity. I > >will describe> >the routine not the code itself since you all know how writte one.> >> >You will need a "bypass function" for "submit".> >1. get the picture file to load on the page.> >2. use the onload event of the image object to check for image filesize.> >3. compare, the actuall f-size with your max limit size, and let the "con-> >ditional" decide what statement to execute.> >4 That is: alert box that tells the user the file exceeds the maximum> >alowed or submit it right away.> >> >And it will all take only a second for the function to complete.> >> >If I wasn't clear, please dont hesitate to ask. I might find some time to> >actually write the code and post it here.> >:)> >Regards> >> > I couldn't help but think there was something like that -- however -- > I couldn't find it. I did read about the FileUpLoad Object, but it > does not provide a size property.> > Would love to see what you might make.> > Cheers,> > tedd> > > -- > -------> http://sperling.com http://ancientstones.com http://earthstones.com> _______________________________________________> Javascript mailing list> Javascript at LaTech.edu> https://lists.LaTech.edu/mailman/listinfo/javascript
_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best web mail—award-winning Windows Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HMWL_mini_pcmag_0707
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20070714/447c5ece/attachment.htm>


More information about the Javascript mailing list