• Mensajes Argumentos
  • Recordar usuario
Entra a el MURO

No estás conectado. Conéctate o registrate

Ver el tema anterior Ver el tema siguiente Ir abajo Mensaje [Página 1 de 1.]

#1 Crear un upload de imagenes php el Mar Sep 06, 2011 1:59 am
Para esto tu tienes que tener un hosting que acepte php,css,entre otros.

Primero vamos a crear unos archivos los cuales son:upload.php;estilo.css y un dirrectorio o carpeta llamada files.Empecemos:
1._Abren el block de notas para empezar a crear el upload.php
2._Pegan este codigo:

Código:
<?php
$status = "";
if ($_POST["action"] == "upload") {
   // obtenemos los datos del archivo
   $tamano = $_FILES["archivo"]['size'];
   $tipo = $_FILES["archivo"]['type'];
   $archivo = $_FILES["archivo"]['name'];
   $prefijo = substr(md5(uniqid(rand())),0,6);
   
   if ($archivo != "") {
      // guardamos el archivo a la carpeta files
      $destino =  "files/".$prefijo."_".$archivo;
      if (copy($_FILES['archivo']['tmp_name'],$destino)) {
         $status = "Archivo subido: <b>".$archivo."</b>";
      } else {
         $status = "Error al subir el archivo";
      }
   } else {
      $status = "Error al subir archivo";
   }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Exluis Archivos</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="413" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="413" height="40" class="titulo">Sube tu imagen en nuestro hosting - by exluis </td>
  </tr>
  <tr>
    <td class="text">Por favor seleccione el archivo a subir:</td>
  </tr>
  <tr>
  <form action="upload.php" method="post" enctype="multipart/form-data">
    <td class="text">
      <input name="archivo" type="file" class="casilla" id="archivo" size="35" />
      <input name="enviar" type="submit" class="boton" id="enviar" value="Subir archivo" />
     <input name="action" type="hidden" value="upload" />     </td>
   </form>
  </tr>
  <tr>
    <td class="text" style="color:#990000"><?php echo $status; ?></td>
  </tr>
  <tr>
    <td height="30" class="subtitulo">Haga clic en el archivo para verlo </td>
  </tr>
  <tr>
    <td class="infsub">
   <?php
   if ($gestor = opendir('files')) {
      echo "<ul>";
       while (false !== ($arch = readdir($gestor))) {
        if ($arch != "." && $arch != "..") {
           echo "<li><a href=\"files/".$arch."\" class=\"linkli\">".$arch."</a></li>\n";
        }
       }
       closedir($gestor);
      echo "</ul>";
   }
   ?>   </td>
  </tr>
</table>
</body>
</html>


3._Luego en guardar como.
4._Desmarcan documento de texto y marcan todos los archivos y lo guardan como hemos dicho:upload.php

5._Luego lo subes a tu hosting o servidor como lo llames
6._En el mismo dirrectorio donde as susbido tu upload.php tienes que crear una carpeta o directorio llamado:files
7._En la carpeta files o dirrectorio files es donde se almacenaran tus imagenes.

8._El estilo del upload es tambien un codigo pero en formato css el cual lo crearemos con el nombre de:estilo.css
9._Hacemos igual para crear el estilo.css como hicimos con el upload sino que aquì cambia el codigo el cual ahora es este:
Código:
.titulo {
   font-family: "Trebuchet MS", Verdana;
   font-size: 18px;
   font-weight: bolder;
   color: #990000;
   text-decoration: none;
   border-top-width: 1px;
   border-bottom-width: 2px;
   border-top-style: solid;
   border-bottom-style: solid;
   border-top-color: #D4D0C8;
   border-bottom-color: #D4D0C8;
   text-align: left;
   padding-left: 30px;
}
.casilla {
   font-family: "Trebuchet MS", Verdana;
   font-size: 11px;
   font-weight: normal;
   color: #999999;
   text-decoration: none;
   border: 1px solid #D4D0C8;
}
.boton {
   border: 1px solid #D4D0C8;
   font-family: "Trebuchet MS", Verdana;
   font-size: 10px;
   font-weight: bold;
   color: #990000;
   text-decoration: none;
   background-color: #D4D0C8;
   vertical-align: middle;
}
.subtitulo {
   font-family: "Trebuchet MS", Verdana;
   font-size: 16px;
   font-weight: bolder;
   color: #999999;
   text-decoration: none;
   text-align: left;
   padding-left: 30px;
}
.subtitulo:hover {
   font-family: "Trebuchet MS", Verdana;
   font-size: 16px;
   font-weight: bolder;
   color: #999999;
   text-decoration: underline;
   text-align: center;
}
.subtext {
   font-family: "Trebuchet MS", Verdana;
   font-size: 12px;
   font-weight: normal;
   color: #999999;
   text-decoration: none;
   text-align: left;
   padding-left: 30px;
   background-color: #EFEFEF;
}
.infsub {

   font-family: "Trebuchet MS", Verdana;
   text-decoration: none;
   border-top-width: 1px;
   border-top-style: solid;
   border-top-color: #D4D0C8;
}
.text {
   font-family: "Trebuchet MS", Verdana;
   font-size: 12px;
   font-weight: normal;
   color: #999999;
   text-decoration: none;
   text-align: left;
   padding-left: 30px;
   padding-top: 10px;
}
.link {

   font-family: "Trebuchet MS", Verdana;
   font-size: 12px;
   font-weight: bolder;
   color: #990000;
   text-decoration: none;
   text-align: center;
}
a.link:hover {


   font-family: "Trebuchet MS", Verdana;
   font-size: 12px;
   font-weight: bolder;
   color: #990000;
   text-decoration: underline;
   text-align: center;
}
li {
   list-style-type: circle;
   font-size: 16px;
   text-decoration: none;
}
.linkli {


   font-family: "Trebuchet MS", Verdana;
   font-size: 12px;
   font-weight: normal;
   color: #0000C0;
   text-decoration: none;
}
a.linkli:hover {



   font-family: "Trebuchet MS", Verdana;
   font-size: 12px;
   font-weight: normal;
   color: #0000C0;
   text-decoration: underline;
}


10._Lo guardamos como estilo.css sin olvidar seleccionar de desmarcar la opcion de documento de texto por todos los archivos y lo guardamos como estilo.css

11._Lo suben y lo aprueban abriendo el upload.php y ya tendran su Subidor de imagenes o upload de imagenes como lo deseen llamar y para aprobarlo entren a mi web y entren a la opcion subir imagenes.



Gracias y esta hecho por exluis
spy spy spy spy spy spy spy spy spy spy spy spy spy spy 1° Puesto 1° Puesto 1° Puesto 1° Puesto 1° Puesto 1° Puesto 1° Puesto 1° Puesto 1° Puesto Pc!! Pc!! Pc!! Pc!! Pc!!

#2 Re: Crear un upload de imagenes php el Vie Oct 07, 2011 7:47 pm
Gracias gran aporte y tutorial.

#3 Re: Crear un upload de imagenes php el Vie Oct 07, 2011 7:48 pm
Ok

#4 Re: Crear un upload de imagenes php el Dom Oct 23, 2011 4:11 pm
Muchas gracias!!

Ver el tema anterior Ver el tema siguiente Volver arriba Mensaje [Página 1 de 1.]

Comparte este tema!

Url directa
BBcode
HTML

Ads

Permiso de este foro: No puedes responder a temas en este foro.

 

Promocionatupagina© Todos los derechos reservados.