Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/10/2015, 04:54
Avatar de xfxstudios
xfxstudios
 
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 10 meses
Puntos: 263
Respuesta: guardar nombre de imagen en base de datos

Código PHP:
Ver original
  1. $idM= filter_input(INPUT_POST, 'idM');
  2.  
  3.  
  4. $objdb = new database();
  5.  $nombre_carpeta = "cabecera"
  6.  
  7. if (!is_dir($nombre_carpeta)) {
  8.     @mkdir($nombre_carpeta, 0700);
  9. }
  10. // A list of permitted file extensions
  11.  
  12. $allowed = array('png', 'jpg', 'gif', 'zip');
  13.  
  14. if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
  15.  
  16.     $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
  17.  
  18.     if (!in_array(strtolower($extension), $allowed)) {
  19.         echo '{"status":"error"}';
  20.         exit;
  21.     }
  22.     $nombreImagen = md5(uniqid(rand() . time())) . "_" . $_FILES['upl']['name'];
  23.  
  24.  
  25.         $objdb->abrir();
  26.         $objdb->sql("CALL   sp_ingresarImagenes('$nombreImagen','$idM')");
  27.         $objdb->cerrar();
  28.    
  29.  
  30.  
  31.     if (move_uploaded_file($_FILES['upl']['tmp_name'], $nombre_carpeta . '/'  
  32.             . $nombreImagen))  
  33.                 {
  34.  
  35. //AQUI COLOCA EL CODIGO DE INSERCION EN TU BASE DE DATOS ("INSERT INTO BLA BLA BLA")
  36.        
  37.         echo '{"status":"success"}';
  38.         exit;
  39.     }
  40. }
  41.  
  42. echo '{"status":"error"}';
__________________
[email protected]
HITCEL