Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/06/2009, 15:09
Avatar de chulifo
chulifo
 
Fecha de Ingreso: abril-2009
Ubicación: perdido en codigos del PHP, pero aprendo rapido!
Mensajes: 524
Antigüedad: 15 años, 10 meses
Puntos: 18
Respuesta: Envio de ficheros al server

mira hace tiempo cree uno gracias a losusaurios de este foro asi que aka e dejoos codigos puedes subir lo q sea


upload.php
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript">
function Abrir_ventana (pagina) {
var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes,";
window.open(pagina,"",opciones);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Manager</title>
<style type="text/css">
<!--
.style1 {
    font-size: 18px;
    font-weight: bold;
}
a:link {
    color: #000000;
}
a:visited {
    color: #000000;
}
a:hover {
    color: #FF0000;
}
a:active {
    color: #000000;
}
-->
</style>
</head>

<body>
<form enctype="multipart/form-data" action="<?=$PHP_SELF?>subir.php" method="POST">
  <p>
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
  selecciona los archivos que quieres subir</p>
  <p>upload 1</p>
  <p>
    <input name="uploadedfile" type="file" />
  </p>
  <p>upload 2</p>
    <p>
      <input name="uploadedfile2" type="file" />
    </p>
    <p>
  </p>
      
      <input type="submit" value="Subir Mi Archivo" />
    </p>
</form>

</html>
Actualemte Estos son los archivos existentes
<p>
<? 
$dir 
= new DirectoryIterator('files');//Aqui se indica la ruta 
while($dir->valid()) { 
if(!
$dir->isDot()) { 
$num++;
print(
"<TD bgcolor=#FFCCFF>"."<a href=borrar.php?files=$dir><img src=\"delete.gif\" title='borrar $dir' border='0'/></font></a>"."</TD>\n"); 

$dir->next('$files'); 
}

?>
<p align="left"><?
$dir 
= new DirectoryIterator('files');//Aqui se indica la ruta 
while($dir->valid()) { 
if(!
$dir->isDot()) { 
$num++;
print(
"<TD bgcolor=#FFCCFF>"."<a href=javascript:Abrir_ventana('files/$dir')><img src=\"open.gif\"   border='0' title='abrir $dir'/></font></a>"."</TD>\n"); 

$dir->next('$files'); 
}
?>
</p>
</body>
subir.php
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
a:link {
    color: #000000;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #000000;
}
a:hover {
    text-decoration: none;
    color: #FF0000;
}
a:active {
    text-decoration: none;
    color: #000000;
}
-->
</style></head>

<body>
<?php
// Where the file is going to be placed  
$target_path "files/"

/* Add the original filename to our target path.   
Result is "uploads/filename.extension" */ 
$target_path $target_path basename$_FILES['uploadedfile']['name']);  

$target_path "files/"

$target_path $target_path basename$_FILES['uploadedfile']['name']);  

if(
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { 
    echo 
"El Archivo ".  basename$_FILES['uploadedfile']['name']).  
    
"\r\n\r\n.Subio exitosamente \r\n\r\n."
} else{ 
    echo 
"Hubo un error en el upload 1. \r\n\r\n."
}  

/////////////// UPLOAD 2 /////////////// 
$target_path "files/"

$target_path $target_path basename$_FILES['uploadedfile2']['name']);  

$target_path "files/"

$target_path $target_path basename$_FILES['uploadedfile2']['name']);  

if(
move_uploaded_file($_FILES['uploadedfile2']['tmp_name'], $target_path)) { 
    echo 
"EL Archivo ".  basename$_FILES['uploadedfile2']['name']).  
    
"Subio exitosamente \r\n\r\n."
} else{ 
    echo 
"Hubo un error en el upload2. \r\n\r\n."
}  
//aki se seecciona los archivos XD solo asi me acuerdo!

?>
<p><strong> <a href="pload.php"><em>Vuelve para ver tus archivos</em></a></strong></p>
</body>
</html>

hay unas nesesitas los 2

hay uan parte q dice delet.gif o loque diga .gif son imagenes para borrar los archivos o abrir los archivos (eso gracias a Trybi)


usalo asi !