Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/08/2013, 11:26
XD2XD2
 
Fecha de Ingreso: diciembre-2012
Mensajes: 223
Antigüedad: 11 años, 5 meses
Puntos: 2
Upload en jQuery

En el archivo js tengo
Código Javascript:
Ver original
  1. $(document).on('click', '#btnlogo', function() {
  2.  
  3.     var data = $('#logo').serialize();
  4.    
  5.     $.post('/logo1.php', data, function(response){
  6.        if(!response == ''){
  7.            $('#error-logo').html('<div class="alert alert-danger">'+response+'</div>');
  8.        }
  9.     });
  10.  
  11.     return false;
  12.  
  13. });

Y el formulario es
Código HTML:
Ver original
  1. <form action="" method="post" class="form-horizontal" enctype="multipart/form-data" id="logo">
  2.       <div id="error-logo"></div>
  3.       <textarea id="elm1" name="title" rows="1" cols="1" style="width: auto;"></textarea>
  4.       <input type="file" name="imagen" size="35">
  5.       <input type="submit" class="btn btn-primary" id="btnlogo" value="Guardar">
  6.       <input type="reset" class="btn btn-danger" value="Restablecer">
  7. </form>

Y por ultimo en el logo1.php tengo
Código PHP:
Ver original
  1. <?php
  2.     echo $_FILES['file']['name'];
  3. ?>
  4. Prueba

Pero al ejecutar todo me sale Prueba y no me sale el nombre del archivo "subido"

Pero si lo ejecuto esto sin jquery si funciona:
Código PHP:
Ver original
  1. <?php
  2. if(isset($_POST['submit'])){
  3.     echo $_FILES['file']['name'];
  4. }
  5. ?>
  6. <form action="" method="post" enctype="multipart/form-data">
  7.     <input name="file" type="file">
  8.     <input type="submit" name="submit">
  9. </form>