Originariamente inviato da m_k_i
Ciao a tutti,ho già postato sul forum scripting, ma non mi hanno saputo aiutare.
Ho trovato uno script on-line che fa al caso mio, o almeno credo, dato che non ci sto capendo molto.
Lo script riconosce la dimensione in pixel dell'immagine che andrò ad uploadare, e fin qui tutto bene.
I problemi sono questi:
Non sono un gran esperto di sintassi JS
Lo script non riconosce le estensioni maiuscole (es. .jpg lo prende, .JPG no)
Lo script visualizza l'immagine in anteprima piccola e ricliccando grande, mostrando le dimensioni, mentre io lo vorrei al primo click.
Una volta riconosciute le dimensioni devo fare un controllo che mi dia una alert se l'immagine è più alta o più larga di 450 pixels.
Mi aiutate a modificare lo script?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>pubblicazione foto</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<STYLE>.divstyle {
HEIGHT: 0px; POSITION: absolute; WIDTH: 0px
}
</STYLE>
<SCRIPT language=JavaScript>
function showimg(form)
{
adres = form.image_file.value;
index = adres.indexOf(".gif");
index = index + adres.indexOf(".jpg");
index = index + adres.indexOf(".bmp");
if (form.image_file.value == "")
{alert("Nessuna Immagine trovata");}
else
{if (index == -3){alert("Formato Immagine non riconosciuto");
form.width.value=0;
form.height.value=0;}
else
{
var img_obj = new Image();
img_obj = form.image_file.value;
document.changing.src = img_obj;
document.changing2.src= img_obj;
document.changing.width = document.changing2.width;
document.changing.height = document.changing2.height;
set();
}
}
}
fast = 0;
change = 0;
function upw(){
document.image.width.value=parseInt(document.image .width.value)+1;
resize();}
function over_upw(){upw();
change = 1;
changetime = setTimeout("fast_upw()","600");}
function fast_upw(){clearTimeout(changetime);
upw();
fast = setTimeout("fast_upw()","100");}
function clt(){
if (change == 1){clearTimeout(changetime);}
clearTimeout(fast);
change = 0;
}
function resize() {document.changing.height = document.image.height.value;
document.changing.width = document.image.width.value;}
function downw(){document.image.width.value=parseInt(docume nt.image.width.value)-1;
resize();}
function over_downw(){downw();
change = 1;
changetime = setTimeout("fast_downw()","600");}
function fast_downw(){clearTimeout(changetime);
downw();
fast = setTimeout("fast_downw()","100");}
function uph(){document.image.height.value=parseInt(documen t.image.height.value)+1;
resize();}
function over_downh(){downh();
change = 1;
changetime = setTimeout("fast_downh()","600");}
function fast_downh(){clearTimeout(changetime);
downh();
fast = setTimeout("fast_downh()","100");}
function over_uph(){uph();
change = 1;
changetime = setTimeout("fast_uph()","600");}
function fast_uph(){clearTimeout(changetime);
uph();
fast = setTimeout("fast_uph()","100");}
function downh(){document.image.height.value=parseInt(docum ent.image.height.value)-1;
resize();}
function set(){
document.image.width.value=document.changing.width ;
document.image.height.value=document.changing.heig ht;}
// End -->
</SCRIPT>
<META content="MSHTML 5.00.3504.2500" name=GENERATOR></HEAD>
<BODY bgColor=#6699CC onload=set() vLink=#0000ff background="bg.jpg">
<CENTER>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD align=middle width="99%">
<CENTER>
<FORM name=image>
<INPUT name=image_file type=file>
<INPUT name=show onclick=showimg(this.form) type=button value="Mostra Immagine">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Larghezza
- Altezza</font><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
</font></p>
<INPUT name=width readOnly size=4>
<font color="#666699"> <font color="#FFFFFF"> _____</font></font>
<INPUT name=height readOnly size=4>
</p>
<TABLE border=1 bordercolor="#000033" cellspacing="4" cellpadding="4" width="121" height="70">
<TBODY>
<TR>
<TD>
<div align="center">[img]300801.gif[/img] </div>
</TD>
</TR>
</TBODY>
</TABLE>
</FORM>
<DIV class=divstyle style="LEFT: 50px; TOP: 250px">
[img]300801.gif[/img]</P>
</DIV>
</CENTER>
</TR>
</TBODY>
</TABLE>
<CENTER>
<CENTER>
</CENTER>
</CENTER></CENTER></BODY></HTML>
Grazie
Ciao