Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/09/2007, 09:04
rashid
 
Fecha de Ingreso: enero-2002
Ubicación: Perez Zeledon Costa Rica
Mensajes: 1.009
Antigüedad: 22 años, 3 meses
Puntos: 11
Subir y reemplazar archivo existente

Hola Amigos.

Tengo un excelente script que permite subir archivos, pero si el archivo ya esta arriba entonces me da error, lo que deseo es lograr que si el archivo existe lo reemplace, alguien puede ayudarme a hacer este pequeño cambio.

Código PHP:
<?php
/* I had tested it in PHP4b3, Apache under windows 95/98 */
/* MultiUP by npguy, [email protected] */

/* Destination of Upload files..use / insted of \\ in UNIX */
define("DESTINATION""/home/.../");

/* Number of Upload files */
define("UPLOAD_NO"2);

echo(
"<p align='center'><b><font size='4'>MultiUP<br>For our USE ONLY!.<br>");

if(
$REQUEST_METHOD!="POST")
{
    print 
"<form enctype=\"multipart/form-data\" method=post>\n";
    print 
"<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"3000000\">\n";

    for(
$i=1$i<=UPLOAD_NO$i++)
    {
        echo 
"<input type=file name=infile$i>&nbsp;&nbsp;&nbsp;&nbsp;";
        
        if(
$i&#37;2==0)
        
print"<br>";
    }
    echo 
"<br><br><input type=submit value=upload></form>\n";
}
else
{
    
/* handle uploads */
    
$noinput true;
    for(
$i=1$noinput && ($i<=UPLOAD_NO); $i++)
    {
        if(${
"infile".$i}!="none"$noinput=false;
    }
    if(
$noinput)
    {
        print 
"<big><B>Error uploading. Try again.</B></big>";
        exit();
    }
echo(
"<p align='center'><b><font size='4'>Successfully Uploaded<br>");

echo(
"<table border='1' width='84%' height='52' bordercolorlight='#008080' bordercolordark='#008080'>
  <tr>
    <td width='14%' bgcolor='#008000' height='21'><font color='#FFFFFF'><b>Sn</b></font></td>
    <td width='52%' bgcolor='#008000' height='21'><font color='#FFFFFF'><b>Filename</b></font></td>
    <td width='34%' bgcolor='#008000' height='21'><font color='#FFFFFF'><b>Size</b></font></td>
    </tr>"
);
  
    for(
$i=1$i<=UPLOAD_NO$i++)
    {
        
        
$just=filesize(${"infile".$i});
        
$fp_size[i] = $just;
        
        if(${
"infile".$i}!="none" &&
         
copy(${"infile".$i}, DESTINATION.${"infile".$i."_name"}) &&
         
unlink(${"infile".$i}))
        {        
        echo(
"<tr>
            <td width='14%' height='19'>$i</td>
            <td width='52%' height='19'>${"infile".$i."_name"}</td>
            <td width='34%' height='19'>$fp_size[i]</td>    
          </tr>
          "
);            
        }
    }
    echo 
"</table>";

?>
gracias