emprit

masih error

Jul 23rd, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.81 KB | None | 0 0
  1. <?php
  2. include CHAPPS_PATH."files/chapps.php";
  3.  
  4. function UploadImage($fupload_name){
  5.   //direktori gambar
  6.   $vdir_upload ='foto_artikel/';
  7.   $vfile_upload = $vdir_upload . $fupload_name;
  8.  
  9.   //Simpan gambar dalam ukuran sebenarnya
  10.   move_uploaded_file($_FILES["portofolioupload"]["tmp_name"], $vfile_upload);
  11.  
  12.   //identitas file asli
  13.     //mencaritahu ekstensi gambar
  14.     $extensi=explode(".",$vfile_upload);
  15.     $ext=end($extensi);
  16.     if($ext == 'jpg' || $ext == 'JEPG'){
  17.         $im_src = imagecreatefromjpeg($vfile_upload);
  18.         $src_width = imageSX($im_src);
  19.         $src_height = imageSY($im_src);
  20.     }
  21.     else if($ext == 'png'){
  22.         $im_src = imagecreatefrompng($vfile_upload);
  23.         $src_width = imageSX($im_src);
  24.         $src_height = imageSY($im_src);
  25.         }
  26.         elseif($ext == 'gif'){
  27.             $im_src = imagecreatefromgif($vfile_upload);
  28.             $src_width = imageSX($im_src);
  29.             $src_height = imageSY($im_src);
  30.             }
  31.            
  32.   //Simpan dalam versi small 110 pixel
  33.   //Set ukuran gambar hasil perubahan
  34.   $dst_width = 110;
  35.   $dst_height = ($dst_width/$src_width)*$src_height;
  36.  
  37.   //proses perubahan ukuran
  38.   $im = imagecreatetruecolor($dst_width,$dst_height);
  39.   imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
  40.        
  41.    
  42.   //Simpan gambar
  43.   imagejpeg($im,$vdir_upload . "small_" . $fupload_name);
  44.  
  45.   //Hapus gambar di memori komputer
  46.   imagedestroy($im_src);
  47.   imagedestroy($im);
  48. }
  49.  
  50. $seminggu = array("Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu");
  51. $hari = date("w");
  52. $hari_ini = $seminggu[$hari];
  53. $tgl_sekarang=date('Y-m-d');
  54. $jam_sekarang=date('H:i');
  55.  
  56.   $lokasi_file    = $_FILES['portofolioupload']['tmp_name'];
  57.   $tipe_file      = $_FILES['portofolioupload']['type'];
  58.   $nama_file      = $_FILES['portofolioupload']['name'];
  59.   $acak           = rand(1,99);
  60.   $nama_file_unik = $acak.$nama_file;
  61.  
  62.   // Apabila ada gambar yang diupload
  63.  
  64. $judul = mysql_real_escape_string($_POST['judul']);  
  65. $isi = mysql_real_escape_string($_POST['keterangan']);
  66.   if (!empty($lokasi_file)){
  67.     UploadImage($nama_file_unik);
  68.     mysql_query("INSERT INTO artikel(id,
  69.                                    judul,
  70.                                    keterangan,
  71.                                    foto)
  72.                            VALUES('',
  73.                                       '$judul',
  74.                                   '$isi',
  75.                                   '$nama_file_unik')")or die(mysql_error());
  76.   }
  77.   else{
  78.     mysql_query("INSERT INTO artikel(id,
  79.                                    judul,
  80.                                    keterangan)
  81.                            VALUES('',
  82.                                       '$judul',
  83.                                   '$isi')")or die(mysql_error());
  84.   }
  85. $hal="portofolio.php";
  86. echo "<meta http-equiv=\"refresh\" content=\"2;url=$hal\">";
  87.   ?>
Advertisement
Add Comment
Please, Sign In to add comment