Como debo de hacerlo? y como puedo definir el tipo de archivo y tamaño maximo de este? Me sirve el código que ya existe y solo debo añadir mas? o debo partir de 0?
Os dejo aquí el código, vuestra ayuda sera de mucha utilidad eso seguro.
Archivo formulario:
Código:
<head> <title>Envío de sugerencias</title> <? echo "<script type=\"text/javascript\">\n"; echo "<!--\n"; echo "function validar(form1) {\n"; echo "if (form1.name.value.length < 2) {\n"; echo "alert('"; echo "Inserte el nombre";; echo "')\n"; echo "form1.name.focus();\n"; echo "return (false);}\n"; echo "var checkOK = \"ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ \" + \"abcdefghijklmnñopqrstuvwxyzáéíóú \";\n"; echo "var checkStr = form1.name.value;\n"; echo "var allValid = true;\n"; echo "var uword = hex_md5(document.getElementById('uword').value)\n"; echo "for (i = 0; i < checkStr.length; i++) {"; echo "ch = checkStr.charAt(i);\n"; echo "for (j = 0; j < checkOK.length; j++)\n"; echo "if (ch == checkOK.charAt(j))\n"; echo "break;\n"; echo "if (j == checkOK.length) {\n"; echo "allValid = false;\n"; echo "break;"; echo "}}\n"; echo "if (!allValid) {\n"; echo "alert('"; echo "inserte el nombre"; echo "');\n"; echo "form1.name.focus();\n"; echo "return (false);}\n"; echo "if ((form1.email.value.indexOf ('@', 0) == -1)||(form1.email.value.length < 9) || form1.email.value.indexOf ('.', 0)== -1 ){\n"; echo "alert('"; echo "inserte el email"; echo "');\n"; echo "form1.email.focus();"; echo "return (false);}\n"; echo "if (form1.message.value.length < 7) {\n"; echo "alert('"; echo "inserte el mensaje"; echo "');\n"; echo "form1.message.focus();"; echo "return (false);}\n"; echo "if (uword==cword[anum-1]) {\n"; echo "return true;}\n"; echo "else {\n"; echo "alert('"; echo "inserte el código de la imagen"; echo "');\n"; echo "document.getElementById('uword').focus();\n"; echo "return false;}\n"; echo "return (true);}\n"; echo "-->\n"; echo "</script>\n"; ?> <script type="text/javascript"> <!-- function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' . Comprueba que esta bien escrito.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+'. Solo numeros.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; } } if (errors) alert('Comprueba los siguientes campos:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> </script> </head> <body onLoad="document.form1.name.focus();"> <div align="center"> <table width="842" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="842" height="40"><img src="../img/carrito.jpg" width="842" height="40" border="0" usemap="#Map" /></td> </tr> </table> <table width="842" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="842" height="161" background="../img/cabecera.jpg"></td> </tr> </table> <table width="842" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="842" height="176" background="../img/cabecera2.jpg"></td> </tr> </table> <table width="842" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="196" height="625" background="../img/dosbotones.jpg"></td> <td width="646" height="625" align="left" valign="top" background="../img/cuadrado-logos-form.jpg"> <form action="gracias_comunidad.php" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return validar(this)"> <div align="center"> <table width="40" border="0" align="center" cellpadding="2"> <tr> <td colspan="2"><div align="justify" class="Estilo8"> <p></p> </div></td> </tr> <tr> <td width="157" align="right" class="Estilo8"><div>Nombre:</div></td> <td width="229"><div align="left"> <input name="name" type="text" class="TAForm" value="" size="30" /> <span class="Estilo10">*</span></div></td> </tr> <tr> <td width="157" align="right" class="Estilo8"><div>Edad::</div></td> <td width="229"><div align="left"> <input name="edad" type="text" class="TAForm" value="" size="2" maxlength="2" id="edad" /> <span class="Estilo10">*</span></div></td> </tr> <tr> <td align="right" class="Estilo8"><div align="right">E-mail:</div></td> <td><div align="left"> <input name="email" type="text" class="TAForm" value="" size="30" /> <span class="Estilo8">Visible?</span> <label> <input name="emailpublico" type="checkbox" id="emailpublico" /> </label> </div></td> </tr> <tr> <td align="right" class="Estilo8"><div align="right">Messenger:</div></td> <td><div align="left"> <input name="msn" type="text" class="TAForm" value="" size="30" /> </div></td> </tr> <tr> <td align="right" class="Estilo8"><div align="right">Poblacíon: </div></td> <td><div align="left"> <input name="poblacion" type="text" class="TAForm" value="" size="30" /> <span class="Estilo10">*</span></div></td> </tr> <tr> <td align="right"><div align="right"><span class="Estilo8">Zona en la comunidad: </span></div> <span class="Estilo8"><label></label> </span> <label> </label></td> <td><div align="left"> <select name="phone" class="TAForm" id="phone"> <option value="Palabra">Palabra</option> <option value="Producto">Producto</option> <option value="Lo mas solidario">Accíon para Se solidario</option> </select> <span class="Estilo10">*</span></div></td> </tr> <tr> <td colspan="2"> <div align="center"> <textarea name="message" cols="85" rows="7" class="TAForm">Escribe aqui la descripcion de la foto.</textarea> </div></td> </tr> <tr> <td align="right" class="Estilo8"><div align="right">Subir foto:: </div></td> <td><div align="left"> <label> <input name="userfile" type="file" class="TAForm" id="imagen" /> </label> <span class="Estilo10">*</span></div></td> </tr> <tr> <td colspan="2"><div align="center"><span class="Estilo8">Inserta el código de la imagen que aparece debajo.</span></div> </tr> <tr> <td align="right" colspan="2"> <div align="center"> <input name="uword" type="text" class="TAForm" id="uword" value="" /> </div></td> </tr> <tr> <td colspan="2"><div align="center"><script type="text/javascript">cimg()</script></div></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" class="TAForm" value="enviar" /> </div></td> </tr> </table> </form> <br /> <br> </td> </tr> </table> <table width="842" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="842" height="36"><img src="../img/pie.jpg" width="842" height="36" /></td> </tr> </table> </div> <map name="Map" id="Map"><area shape="rect" coords="660,3,830,37" href="../tienda/contact_us.html" alt="Contacto" /> </map></body> </html>