Este es el formulario completo: (Tanto el formulario como la acción están en el mismo archivo).
Código PHP:
<form name="formulario" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<tr>
<td colspan="2" class="tabla_titulo"><div align="center"><strong><?=_NUEVO_MENSAJE_?> </strong></div></td>
</tr>
<tr>
<td width="12%" class="tabla_contenido"><strong><?=_PARA_?></strong></td>
<td width="88%" class="tabla_contenido"><input name="destinatario" type="text" id="destinatario" value="<? echo"$_GET[usereply]";?>" size="60">
<input name="Submit" type="button" value="<?=_SELECT_?>" onClick="abrir('para.php','200','700')">
<input name="adjuntar" type="button" value="Adjuntar" onClick="abrir('Subirarchivo2.php','300','300')"> </td>
</tr>
<tr>
<td class="tabla_contenido"><strong><?=_ASUNTO_?></strong></td>
<td class="tabla_contenido"><input name="asunto" type="text" id="asunto" value="<? if($_GET[ac]=="responder") { echo"RE: $asunto"; } ?>" size="75"></td>
</tr>
<tr>
<td class="tabla_contenido" valign="top"><strong><?=_MENSAJE_?></strong></td>
<textarea name="mensaje" cols="75" rows="15" id="mensaje" onKeyUp="caracteres()"></textarea>
<br>
<?=_LEQUEDAN_?>
<input type="text" name="contador" size="4">
<?=_C_D_?></td>
</tr>
<tr><td colspan="2" class="tabla_contenido"><div id="sub3" hidden="" align="center">
Archivo: <input name="archivo" type="file" size="35" />
<input name="archivo" type="submit" value="Enviar" />
<input name="action" type="hidden" value="upload" />
<input type="button" name="type" value='Cancelar Archivo' onClick="setVisibility('sub3', 'none');"; align="right">
</div></td></tr>
<tr>
<td colspan="2" class="tabla_contenido"><div align="center">
<input name="enviar" type="submit" id="enviar" value="<?=_ENVIAR_MENSAJE_?>">
<input name="Submit" type="reset" value="<?=_BORRAR_?>">
</div></td>
</tr>
</form>
Aquí está la acción, AQUÍ EL PROBLEMA! (solo la parte donde se carga el archivo):
Código PHP:
if($_POST['enviar']) {
$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 = "archivosubido/".$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";
}
...