wawandx

Can't move_upload_file to hosting

Feb 7th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. if ($act=='update'){
  2. $lokasi_file = $_FILES['image']['tmp_name'];
  3. $tipe_file = $_FILES['image']['type'];
  4. $nama_file = $_FILES['image']['name'];
  5. $acak = rand(1,99);
  6. $nama_file_unik = $acak.$nama_file;
  7.  
  8.  
  9. if (empty($lokasi_file)){
  10. $update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
  11. detail='$_POST[kata]',
  12. link='$_POST[link]'
  13. WHERE kd_slide = '$_POST[kd_slide]'");
  14. }
  15. else{
  16. UploadImage1($nama_file_unik);
  17. $update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
  18. detail='$_POST[kata]',
  19. link='$_POST[link]',
  20. image='$nama_file_unik'
  21. WHERE kd_slide = '$_POST[kd_slide]'");
  22. }
  23. if($update ==FALSE){
  24. echo '
  25. <div class="wrapper-page">
  26. <div class="ex-page-content text-center">
  27. <h2>Gagal Edit Data</h2>
  28. <br>
  29. <p class="text-muted">
  30. Hubungi admin untuk perbaiki.
  31. </p>
  32. <br>
  33. <a class="btn btn-default waves-effect waves-light" href="admin.php"> Return Home</a>
  34.  
  35. </div>
  36. </div>
  37. ';
  38. }
  39. header('location:admin.php?page=slide');
  40. }
  41.  
  42.  
  43.  
  44. function UploadImage1($fupload_name){
  45. //direktori gambar
  46. $vdir_upload = "../images/slider/";
  47. $vfile_upload = $vdir_upload . $fupload_name;
  48.  
  49. //chmod("$vfile_upload", 0644);
  50.  
  51. //Simpan gambar dalam ukuran sebenarnya
  52. move_uploaded_file($_FILES["image"]["tmp_name"], $vfile_upload);
  53.  
  54. //identitas file asli
  55. $im_src = imagecreatefromjpeg($vfile_upload);
  56. $src_width = imageSX($im_src);
  57. $src_height = imageSY($im_src);
  58.  
  59. //Simpan dalam versi small 1920 pixel
  60. //Set ukuran gambar hasil perubahan
  61. $dst_width = 1920;
  62. $dst_height = ($dst_width/$src_width)*$src_height;
  63.  
  64. //proses perubahan ukuran
  65. $im = imagecreatetruecolor($dst_width,$dst_height);
  66. imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
  67.  
  68. //Simpan gambar
  69. imagejpeg($im,$vdir_upload . "small_" . $fupload_name);
  70.  
  71. //Hapus gambar di memori komputer
  72. imagedestroy($im_src);
  73. imagedestroy($im);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment