Foros del Web » Programando para Internet » PHP »

Hosting de imagenes con PHP ayuda simple

Estas en el tema de Hosting de imagenes con PHP ayuda simple en el foro de PHP en Foros del Web. Hola tengo el siguiente codigo para colocado en mi web: Lap agina principal de hosting: Código PHP: <form action="manu.php" method="post" enctype="multipart/form-data">       <input name="imagen" type="file" size="35" />       <input name="enviar" type="submit" value="Upload Image" />       <input name="action" type="hidden" value="upload" />       </form>               <?php  ...
  #1 (permalink)  
Antiguo 17/05/2008, 11:01
Avatar de manumaf  
Fecha de Ingreso: mayo-2007
Ubicación: Argentina
Mensajes: 854
Antigüedad: 16 años, 11 meses
Puntos: 6
Hosting de imagenes con PHP ayuda simple

Hola tengo el siguiente codigo para colocado en mi web:

Lap agina principal de hosting:
Código PHP:
<form action="manu.php" method="post" enctype="multipart/form-data">
      <input name="imagen" type="file" size="35" />
      <input name="enviar" type="submit" value="Upload Image" />
      <input name="action" type="hidden" value="upload" />
      </form>
      
      <?php if ($varstat == "ok") { ?>
      <strong>Confirmacion:</strong><br>
      Archivo publicado satisfactoriamente.
      Puedes utilizar las siguientes opciones para enlazarlo:<br>
      <strong>Enlace Directo: </strong><br>
      <input name="txt2" type="text" value="<?php echo $varpath?>">
      <img src="tmp/<?php echo $varname?>">
      <?php ?>

      <?php if ($_GET['image'] != "") { ?>
      <img src="tmp/<?php echo $_GET['image']; ?>">
      <?php ?>


Y la accion del formulario:

Código PHP:
<?php
      $varrand 
substr(md5(uniqid(rand())),0,10);       
      
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
      
$varpath "http://www.habbotools.com.ar/hostimg?image=";
      
$varstat "";

      if (
is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
          
$varname $_FILES["imagen"]['name'];
          
$vartemp $_FILES['imagen']['tmp_name'];
         
$vartype mime_content_type($vartemp); 
          
          
          {
          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";
          }
}
?>
Me salta error en la linea 10 que seria:
Código PHP:
$vartype mime_content_type($vartemp); 


Alguien me puede ayudar?
  #2 (permalink)  
Antiguo 17/05/2008, 11:25
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Hosting de imagenes con PHP ayuda simple

ke error te dice??
recuerda ke no es necesaria una funcion para saber el MIME del archivo en cuestion...

la misma global $_FILES contiene tal informacion, no?
  #3 (permalink)  
Antiguo 17/05/2008, 11:33
Avatar de manumaf  
Fecha de Ingreso: mayo-2007
Ubicación: Argentina
Mensajes: 854
Antigüedad: 16 años, 11 meses
Puntos: 6
Respuesta: Hosting de imagenes con PHP ayuda simple

Si no coloco esa linea la pagina se queda en blanco y no se carga y si la coloco me dise lo siguiente:

Fatal error: Call to undefined function mime_content_type() in /home/manumaf/domains/habbotools.com.ar/public_html/hostimg/index.php on line 37


on line 37 que seria donde esta mime_content_type()


Como lo arreglo?
  #4 (permalink)  
Antiguo 17/05/2008, 11:39
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Hosting de imagenes con PHP ayuda simple

Cambia esa linea por:
Código PHP:
$vartype $_FILES['imagen']['type']; 
Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:17.