Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/02/2013, 14:36
luisochonews
 
Fecha de Ingreso: agosto-2012
Mensajes: 77
Antigüedad: 11 años, 9 meses
Puntos: 0
Pregunta Solo se envia el mensaje pero no el archivo :(

Buenas Tardes, les comento que tengo un sistema de usuarios con mensajes privados, y a este le quise agregar que se pueda adjuntar 1 archivo, el problema, es que solo me envia el mensaje pero el archivo no :(. Si alguien tiene un aporte o quiere hacerme correciones, yo con gusto se los recibo :)

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";
    }
... 

Última edición por luisochonews; 09/02/2013 a las 14:46 Razón: ES URGENTE!!!