Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $update=true;
- if ($act=='update'){
- $lokasi_file = $_FILES['image']['tmp_name'];
- $tipe_file = $_FILES['image']['type'];
- $nama_file = $_FILES['image']['name'];
- $acak = rand(1,99);
- $nama_file_unik = $acak.$nama_file;
- if (empty($lokasi_file)){
- $update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
- detail='$_POST[kata]',
- link='$_POST[link]'
- WHERE kd_slide = '$_POST[kd_slide]'");
- }
- else{
- if( UploadImage1($nama_file_unik)){
- $update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
- detail='$_POST[kata]',
- link='$_POST[link]',
- image='$nama_file_unik'
- WHERE kd_slide = '$_POST[kd_slide]'");
- }
- else{
- $update=false;
- }
- }
- }else{
- $update=false;
- }
- if($update ===FALSE){
- echo '
- <div class="wrapper-page">
- <div class="ex-page-content text-center">
- <h2>Gagal Edit Data</h2>
- <br>
- <p class="text-muted">
- Hubungi admin untuk perbaiki.
- </p>
- <br>
- <a class="btn btn-default waves-effect waves-light" href="admin.php"> Return Home</a>
- </div>
- </div>
- ';
- }
- else{
- header('location:admin.php?page=slide');exit();
- }
- function UploadImage1($fupload_name){
- //direktori gambar
- $vdir_upload = "../images/slider/";
- $vfile_upload = $vdir_upload . $fupload_name;
- //chmod("$vfile_upload", 0644);
- //Simpan gambar dalam ukuran sebenarnya
- if(copy($_FILES["image"]["tmp_name"], $vfile_upload)){
- //identitas file asli
- $im_src = imagecreatefromjpeg($vfile_upload);
- $src_width = imageSX($im_src);
- $src_height = imageSY($im_src);
- //Simpan dalam versi small 1920 pixel
- //Set ukuran gambar hasil perubahan
- $dst_width = 1920;
- $dst_height = ($dst_width/$src_width)*$src_height;
- //proses perubahan ukuran
- $im = imagecreatetruecolor($dst_width,$dst_height);
- imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
- //Simpan gambar
- imagejpeg($im,$vdir_upload . "small_" . $fupload_name);
- //Hapus gambar di memori komputer
- imagedestroy($im_src);
- imagedestroy($im);
- }else{
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement