Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/04/2010, 08:17
den_22
 
Fecha de Ingreso: enero-2010
Mensajes: 198
Antigüedad: 14 años, 3 meses
Puntos: 1
Imagenes que no se insertan

Hola amigos, que tal, les comento que estoy haciendo el codigo para subir archivos a el perfil del usuario, y tengo este codigo que es el que hace la subida del archivo, pero no se logra insertar a la base de datos.

Dejo el código para ver si me pueden ayudar.

Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4.  
  5. error_reporting(E_ALL ^ E_NOTICE);
  6. session_name('pLogin');
  7. session_set_cookie_params(2 * 7 * 24 * 60 * 60);
  8.  
  9. include ("connect.php");
  10. include ("function.php");
  11.  
  12. $id = $_SESSION["id"];
  13.  
  14.  
  15. $query = mysql_query("select * from prueba where id='$_SESSION[id]'");
  16.  
  17. $get = mysql_fetch_array($query);
  18.  
  19. $id = $getname["id"];
  20. $firstname = $getname["firstname"];
  21. $image1 = $getname["image1"];
  22.  
  23. $image2 = $getname["image2"];
  24.  
  25. $image3 = $getname["image3"];
  26.  
  27.  
  28. if ($image1 != "") {
  29.  
  30.     if ($image2 != "") {
  31.  
  32.         if ($image3 != "") {
  33.  
  34.             $curr_image = $id . "_3";
  35.  
  36.         } else
  37.             $curr_image = $id . "_3";
  38.  
  39.     } else
  40.         $curr_image = $id . "_2";
  41.  
  42. } else
  43.     $curr_image = $id . "_1";
  44.  
  45.  
  46. if ($_REQUEST[callid] == 2) {
  47.    
  48.     $ph1 = $HTTP_POST_FILES['userfile']['name'];
  49.     $userfile = $_FILES['userfile']['tmp_name'];
  50.  
  51.     if ($ph1 != "") {
  52.         $path1 = "photo/";
  53.         $extension1 = substr($ph1, strlen($ph1) - 4);
  54.         $imagefile = "$curr_image" . "$extension1";
  55.         $dest1 = $path1 . $imagefile;
  56.         if (is_uploaded_file($userfile)) {
  57.             @copy($userfile, $dest1);
  58.         } //if
  59.     } //if
  60.     //$imagefile = image_upload($userfile, $image, "photo/", 90, 90, 100, 0) or die("error");
  61.  
  62.     if ($curr_image == $id . "_1") {
  63.  
  64.         @mysql_query("update prueba set image1= '$imagefile',curr_image='$imagefile',cap1='$Caption' where id='$_SESSION[id]'");
  65.  
  66.     }
  67.  
  68.     if ($curr_image == $id . "_2") {
  69.  
  70.         $query = "update prueba set image2= '$imagefile',curr_image='$imagefile',cap2='$Caption' where id='$_SESSION[id]'";
  71.  
  72.         @mysql_query($query);
  73.  
  74.     }
  75.  
  76.     if ($curr_image == $id . "_3") {
  77.  
  78.         @mysql_query("update prueba set image3= '$imagefile',curr_image='$imagefile',cap3='$Caption' where id='$_SESSION[id]'");
  79.  
  80.     }
  81.  
  82.  
  83. }
  84.  
  85.  
  86. function image_upload($userfile, $newfile, $directory, $width, $height, $quality =
  87.     '100', $smooth = '10', $extention = 'AUTO')
  88. {
  89.  
  90.  
  91.     $imgsize = GetImageSize($userfile);
  92.  
  93.  
  94.     if (($imgsize[0] > $width) || ($imgsize[1] > $height)) {
  95.  
  96.         $tmpimg = @tempnam("./photo", "MKUP");
  97.  
  98.         system("djpeg $userfile >$tmpimg");
  99.  
  100.         system("pnmscale -xy $width $height $tmpimg | cjpeg -smoo $smooth -qual $quality  >$userfile");
  101.  
  102.         //     unlink($tmpimg);
  103.  
  104.     }
  105.  
  106.     $mimetype = $_FILES['userfile']['type'];
  107.  
  108.  
  109.     if ($extention == "AUTO") {
  110.  
  111.         if (($mimetype == "image/x-png") || ($mimetype == "image/png")) {
  112.  
  113.             $extention = "png";
  114.  
  115.         } elseif ($mimetype == "image/pjpeg") {
  116.  
  117.             $extention = "jpg";
  118.  
  119.         } elseif ($mimetype == "image/gif") {
  120.  
  121.             $extention = "gif";
  122.  
  123.         } else {
  124.  
  125.             $extention = "";
  126.  
  127.             $error_message = "Please upload images with the extension .jpg or .jpeg or .gif or .png only";
  128.  
  129.         }
  130.  
  131.     }
  132.  
  133.  
  134.     if (strstr($mimetype, "photo/")) {
  135.  
  136.         $newfile_name = $newfile . "." . $extention;
  137.  
  138.         $newfile = $directory . $newfile_name;
  139.  
  140.  
  141.         if (is_uploaded_file($userfile)) {
  142.  
  143.  
  144.             if (!copy($userfile, $newfile)) {
  145.  
  146.  
  147.                 $error_message = "Error Uploading File.";
  148.  
  149.             }
  150.  
  151.  
  152.         }
  153.  
  154.  
  155.         return $newfile_name;
  156.  
  157.  
  158.     } else {
  159.  
  160.        
  161.  
  162.         $error_message = "Not An Image";
  163.  
  164.     }
  165.  
  166.  
  167. }
  168.  
  169. if ($error_message == "") {
  170. } else {
  171.  
  172.     echo $error_message;
  173.  
  174. }
  175.  
  176. ?>


Gracias de antemano, den_22