Tema: True y False
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2007, 20:44
gesking
 
Fecha de Ingreso: diciembre-2006
Mensajes: 294
Antigüedad: 17 años, 4 meses
Puntos: 2
True y False

Hola, tengo un script donde subo imágenes pero solo quiero subir JPG, GIF y PNG...

Este es el script como hago???

Código PHP:
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%">
<div align="center">
<form action="index.php" method="post" enctype="multipart/form-data" name="form1">
<span class="Estilo2">Archivo</span>
<br>
<input name="archivo" type="file" id="archivo" class="file">
<br><br>
<input name="boton" id="boton" class="boton" type="submit" value="Subir Imagen!">
</form>
</div>
</td>
<td width="50%" style="border: 1px solid #0099FF; background-color: #88CFFF">
<b>Solo se admiten archivo con formato JPG, GIF y PNG.</b>
<br>
Tamaño máximo aceptado:<span style="color:#FF0000"> 300KB</span>.
</td>
</tr>
</table>
<br><br>
<?
if($boton) {

$tipo $_FILES['archivo']['type'];
$tamaño $_FILES['archivo']['size'];

if (
is_uploaded_file($HTTP_POST_FILES['archivo']['tmp_name'])) {

if(
$HTTP_POST_FILES['archivo']['size'] < 300000) {

if(
$HTTP_POST_FILES['archivo']['type']=="image/gif" || "image/jpeg" || "image/png") {
$info pathinfo($_FILES['archivo']['name']);
$nnombre substr(md5(uniqid(rand())),0,10).".".$info['extension'];
$destino =  "".$nnombre;
copy($_FILES['archivo']['tmp_name'], $destino);

$subio true;
}
}
}

   if(
$subio) {
      echo 
'<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td>
<div align="center">
<img src="'
.$nnombre.'">
</div>
</td>
</tr>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%">
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
</tr>
<tr>
<td>
<div align="center">
<b>URL</b>
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<textarea name="textarea4" cols="50" rows="2" class="file">http://www.host-image.com.ar/'
.$nnombre.'</textarea>
</div>
</td>
</tr>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
<div align="center">
<b>C&oacute;digo para foros</b>
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<textarea name="textarea4" cols="50" rows="2" class="file">[url=http://www.host-image.com.ar][img=http://www.host-image.com.ar/'
.$nnombre.'][/url]</textarea>
</div>
</td>
</tr>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
<div align="center">
<b>C&oacute;digo HTML</b>
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<textarea name="textarea4" cols="50" rows="2" class="file"><a href="http://www.host-image.com.ar"><img src="http://www.host-image.com.ar/'
.$nnombre.'" border="0" /></a></textarea>
</div>
</td>
</tr>
</table>
</td>
<td width="50%" valign="top">
<br><br>
   <b>Nombre:</b>    <a href="'
.$nnombre.'" target="_blank">'.$nnombre.'</a>
<br><br>
   <b>Tipo:</b>    "'
.$tipo.'"
<br><br>
   <b>Tamaño:</b>    <span style="color:#FF0000">"'
.$tamaño.'"</span> bytes
</td>
</tr>
</table>
</td>
</tr>
</table>'
;
   } else {
      echo 
"El archivo no se pudo enviar. Recuerda que debe ser un archivo JPG, GIF o PNG y el tamaño no puede exceder los 300KB";
   }
   die();
}