tHeEkiZdeH
Usuario habitual
Usuario habitual

Hola, les queria decir de que mi codigo es este:

<?php
$varrand = substr(md5(uniqid(rand())),0,10);  
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image /x-png");
$varpath = "
https://xxx.webcindario.com/upload.php?image=";
$varstat = "";

if ($_POST["action"] == "upload") {
 if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
  $varname = $_FILES["imagen"]['name'];
  $vartemp = $_FILES['imagen']['tmp_name'];
  $vartype = mime_content_type($vartemp); <--- Linea 11
  
  if (in_array($vartype, $varallw) && $varname != "") {
   $arrname = explode(".", $varname);
   $varname = $varrand.".".$arrname[1];
   if (copy($vartemp, "tmp/".$varname)) {
    $varpath = $varpath.$varname;
    $varstat = "ok";
   } else {
    $varstat = "Error al subir el archivo";
   }
  } else {
   $varstat = "Archivo no valido";
  }
 }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>La Web</title>
<link href="cssupload.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="413" height="40">La Web</td>
  </tr>
  <tr>
    <td>La Web</td>
  </tr>
  <tr>
  <form action="upload.php" method="post" enctype="multipart/form-data">
    <td height="50" valign="top">
      <input name="imagen" type="file" id="imagen" size="35" />
      <input name="enviar" type="submit" id="enviar" value="Subir Imagen" />
   <input name="action" type="hidden" value="upload" />   </td>
 </form>
  </tr>
  <?php if ($varstat == "ok") { ?>
  <tr>
    <td><strong>Confirmaci&oacute;n:</strong><br>
 Archivo subido satisfactoriamente. Puedes utilizar las siguientes opciones para enlazarlo:<br>
 <strong>Enlace HTML:</strong> <br>
 <input name='txt1' type='text' value='<a href="<?php echo $varpath; ?>"><img src="<?php echo $varpath; ?>" border="0" /></a>' size='60'>
 <br>
 <strong>Enlace Directo: </strong><br>
 <input name='txt2' type='text' value='<?php echo $varpath; ?>' size='60'></td>
  </tr>
  <?php } else { ?>
   <?php if ($varstat != "") { ?>
   <tr>
  <td><strong>Error:</strong><br>
     <?php echo $varstat; ?>&nbsp;</td>
   </tr>
   <?php } ?>
  <?php } ?>
</table>
<?php if ($varstat == "ok") { ?>
<p align="center"><img src="tmp/<?php echo $varname; ?>"></p>
<?php } ?>
<?php if ($_GET['image'] != "") { ?>
<p align="center"><img src="tmp/<?php echo $_GET['image']; ?>"></p>
<?php } ?>
</body>
</html>

Y el error que me da es:

Fatal error: Call to undefined function mime_content_type() in /home/webcindario/p/r/proupload-1/upload.php on line 11

Avatar Image
Come y duerme en el foro
Come y duerme en el foro

Ya he visto ese codigo anteriormente. Hablan del error que mencionas. Y tambien existe buena informacion en http://www.php.net/mime_content_type.

Este es el que yo utilizaba y no me iba mal :

Spoiler:

<form enctype="multipart/form-data"  method="post" action="<?php $_PHP_SELF;?>">
<!--Campo oculto para limitar el tamanyo
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<!-- tamaño en bytes 1kB=1024 1MB=1.048.576 
Elige imagen:   <input name="userfile" type="file"><br><br>
<input type="submit" value="aceptar" name="button">
</form> 
<br> 
<?php  
if($button)
{

//TIPO PJPEG para IE
if ($_FILES['userfile']['type']=="image/jpeg" || ($_FILES['userfile']['type']=="image/pjpeg") )
{
   
 
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
   echo "El archivo ". $_FILES['userfile']['name'] ." ha sido subido con exito\n"."<br>";
   //readfile($_FILES['userfile']['tmp_name']);
 
  
//Con time podran subir archivos con mismo nombre   
$nombre_fichero=time().'__'.$_FILES['userfile']['name']; 
$nombre_fichero='fotos/'.$_FILES['userfile']['name']; 
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $nombre_fichero))
    {
    
      echo "Imagen correcta";  
    }   
    else
    { echo "No se ha podido subir la imagen";
      print_r($_FILES);
    } 
   }      
echo "Mostrando la imagen<br>"; 
echo '<img src="'. $nombre_fichero .'">';


//En caso de que no sea un jpg, no permitir el envio
else
 {  
 echo "El tipo de fichero no es valido";
 }
}//IF button 
?> 
  -->

Lo hize limitado solo para imagenes en .jpg , pero perfectamente se puede hacer para los otros tipos : gif,png,bmp, etc etc. Tambien esta limitado el tamaño aunque deduzo que aunque no hubiera tope, el servidor no dejaria subir archivos de gran capacidad.

Como ya dije es muy antiguo pero se le puede pulir y sacarle mas partido. Saludos.

tHeEkiZdeH
Usuario habitual
Usuario habitual

Ok, pero a mi me gustaria que ojala que alguno de ustedes me puedan alludar con la linea 11 a resolverla porfavor, se los agradeceria muchisimo.

Desde ya gracias.

Overlick
Usuario habitual
Usuario habitual

Prueba reeplazarla por esto:

  $vartype = $_FILES['imagen']['type'];

tHeEkiZdeH
Usuario habitual
Usuario habitual

Muchiiiiiiiiiiiiiiiiiiiiiiiisimas gracias!, good! me funciono perfectamente, muchas gracias por tu ayuda amigo.

Hasta luego y un saludo.

ATENCIÓN: Este tema no tiene actividad desde hace más de 6 MESES,
te recomendamos abrir un nuevo tema en lugar de responder al actual
Opciones:
Ir al subforo:
Permisos:
TU NO PUEDES Escribir nuevos temas
TU NO PUEDES Responder a los temas
TU NO PUEDES Editar tus propios mensajes
TU NO PUEDES Borrar tus propios mensajes
Temas similares
TemaUsuariosRespuestasVisitasActividad
Por: , el 17/Sep/2009, 08:27
tHeEkiZdeH NoSetup.org34kSep/09
Por: , el 27/Ene/2009, 21:39
nixoweb GestionXls3992Jan/09
Por: , el 09/Ago/2003, 01:59
NaRkODJ02kAug/03