Código PHP:
<?php
// Configuración //
///////////////////
// $extensiones=array("1ªext","2ªext","....");
// Aqui debes poner las extensiones que NO admitas
// por ejemplo si no quieres admitir .html , .exe ni .gif :
// $extensiones=array("html","exe","gif");
///////////////////////////////////////
$extensiones=array("");
/////////////////
// $path="/ruta/ta/ta";
// Si el server rula bajo LinuX toda la ruta completa /var/etc/..
// Si rulas bajo WindoWs C:/midirectorioroot/tal..
// Nota: Sin el último / ej: C:/miweb NO C:/miweb/
////////////////
set_time_limit(600);
$path="C:/Inetpub\wwwroot\sec2\oficios";
$nombre=$HTTP_POST_FILES['archivo']['name'];
$tamanio=$HTTP_POST_FILES['archivo']['size'];
$tipo=$HTTP_POST_FILES['archivo']['type'];
$var = explode(".","$nombre");
$num = count($extensiones);
$valor = $num-1;
for($i=0; $i<=$valor; $i++) {
if($extensiones[$i] == $var[1]) {
echo "<center><table>
<tr>
<td height='100' width='30' class='ti_12_negro' ></td>
</tr>
<tr>
<td height='40' width='330' align='center' class='ti_12_negro' bgcolor='#CCFFFF'>Archivo no admitido</td>
</tr>
<tr>
<td height='30'></td>
</tr>
<tr>
<td height='40' width='330' align='center'><input type='button' class='button' name='cmdsalir' value='Salir' onclick='javascript:window.close();'></td>
</tr>
</table>";
exit;
}
}
$nombre_archivo = $_POST["num_oficio"].substr($nombre, strlen($nombre) - 4, 4);
if (is_uploaded_file($HTTP_POST_FILES['archivo']['tmp_name']))
{
copy($HTTP_POST_FILES['archivo']['tmp_name'], "$path/$nombre_archivo");
echo "<center>
<table>
<tr>
<td height='100' width='30' class='ti_12_negro' ></td>
</tr>
<tr>
<td height='40' width='330' align='center' class='ti_12_negro' bgcolor='#CCFFFF'>Datos ingresados correctamente!</td>
</tr>
<tr>
<td height='30'></td>
</tr>
<tr>
<td height='40' width='330' align='center'></td>
</tr>
</table>";
}
else
{
echo "<center>
<table>
<tr>
<td height='100' width='30' class='ti_12_negro' ></td>
</tr>
<tr>
<td height='40' width='330' align='center' class='ti_12_negro' bgcolor='#CCFFFF'>Error al subir el archivo</td>
</tr>
<tr>
<td height='20'></td>
</tr>
</table>";
}
?>