Foros del Web » Programando para Internet » PHP »

(Duda)Upload

Estas en el tema de (Duda)Upload en el foro de PHP en Foros del Web. Resulta que tengo un hosting y tengo un codigo nececito hacer no se si se puede pero nececito hacer para que aparesca el url al ...
  #1 (permalink)  
Antiguo 24/01/2012, 18:19
 
Fecha de Ingreso: junio-2011
Mensajes: 15
Antigüedad: 12 años, 11 meses
Puntos: 1
Exclamación (Duda)Upload

Resulta que tengo un hosting y tengo un codigo nececito hacer no se si se puede pero nececito hacer para que aparesca el url al subir el archivo aquí el codigo

Código PHP:
<?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>Upload Archivos</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<center><table width="413" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="413" height="40" class="titulo"><center>Upload Staff Privado</center></td>
  </tr>
  <tr>
    <td class="text"><center>Por favor seleccione el archivo a subir:</center></td>
  </tr>
  <tr>
  <form action="index.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="Enviar" />
      <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"><center>Listado de Archivos Subidos</center> </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></center>
<br>
 <td height="30" class="titulo"><center>Staff Encargado de la Seguridad</center> </td>
 <td height="30" class="titulo"><center>UploadA</center> </td>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<td height="30" class="titulo"><center>Powered By Upload Archivos, © 2012 UploadA Group</center> </td>

</body>
</html>
Saludos
  #2 (permalink)  
Antiguo 25/01/2012, 07:08
Avatar de CesarHC  
Fecha de Ingreso: junio-2011
Ubicación: localhost
Mensajes: 566
Antigüedad: 12 años, 11 meses
Puntos: 56
Respuesta: (Duda)Upload

Pues es algo asi:

Código PHP:
Ver original
  1. //PONES EN UNA VARIABLE LA RUTA HASTA LA CARPETA DESTINO
  2. $url= "http://localhost/tupagina/imagenes/";
  3. //SACAS E NOMBRE DEL ARCHIVO A SUBIR
  4.         $name= ($_FILES['fichero']['name']);
  5. //LE DAMOS LA URL COMPLETA Y LISTO
  6.         $urlfina= $url . $name;
__________________
Solo la práctica no te traicionara ¡¡¡¡¡¡

Seguir el camino tu debes PHP The Right Way.

Etiquetas: html
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 08:19.