View difference between Paste ID: 82St7XUG and SCDiGbgs
SHOW: | | - or go back to the newest paste.
1
<?php 
2-
$lokasi_file = $_FILES['image']['tmp_name'];
2+
$update=true;
3-
$tipe_file = $_FILES['image']['type'];
3+
4-
$nama_file = $_FILES['image']['name'];
4+
	$lokasi_file = $_FILES['image']['tmp_name'];
5-
$acak = rand(1,99);
5+
	$tipe_file = $_FILES['image']['type'];
6-
$nama_file_unik = $acak.$nama_file;
6+
	$nama_file = $_FILES['image']['name'];
7
	$acak = rand(1,99);
8
	$nama_file_unik = $acak.$nama_file;
9-
if (empty($lokasi_file)){
9+
10-
$update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
10+
11-
detail='$_POST[kata]',
11+
	if (empty($lokasi_file)){
12-
link='$_POST[link]'
12+
		$update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
13-
WHERE kd_slide = '$_POST[kd_slide]'");
13+
		detail='$_POST[kata]',
14
		link='$_POST[link]'
15
		WHERE kd_slide = '$_POST[kd_slide]'");
16-
UploadImage1($nama_file_unik);
16+
	}
17-
$update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
17+
	else{
18-
detail='$_POST[kata]',
18+
		if( UploadImage1($nama_file_unik)){
19-
link='$_POST[link]',
19+
			$update=mysql_query("UPDATE slide SET judul='$_POST[judul]',
20-
image='$nama_file_unik'
20+
			detail='$_POST[kata]',
21-
WHERE kd_slide = '$_POST[kd_slide]'");
21+
			link='$_POST[link]',
22
			image='$nama_file_unik'
23-
if($update ==FALSE){
23+
			WHERE kd_slide = '$_POST[kd_slide]'");
24-
echo '
24+
		}
25-
<div class="wrapper-page">
25+
		else{ 
26-
<div class="ex-page-content text-center">
26+
			$update=false;
27-
<h2>Gagal Edit Data</h2>
27+
		}
28-
<br>
28+
	}
29-
<p class="text-muted">
29+
	
30-
Hubungi admin untuk perbaiki.
30+
	
31-
</p>
31+
}else{ 
32-
<br>
32+
	$update=false;
33-
<a class="btn btn-default waves-effect waves-light" href="admin.php"> Return Home</a>
33+
34
35-
</div>
35+
if($update ===FALSE){
36-
</div>
36+
		echo '
37-
';
37+
		<div class="wrapper-page">
38
		<div class="ex-page-content text-center">
39-
header('location:admin.php?page=slide');
39+
		<h2>Gagal Edit Data</h2>
40
		<br>
41
		<p class="text-muted">
42
		Hubungi admin untuk perbaiki.
43
		</p>
44
		<br>
45-
//direktori gambar
45+
		<a class="btn btn-default waves-effect waves-light" href="admin.php"> Return Home</a>
46-
$vdir_upload = "../images/slider/";
46+
47-
$vfile_upload = $vdir_upload . $fupload_name;
47+
		</div>
48
		</div>
49-
//chmod("$vfile_upload", 0644);
49+
		';
50
}
51-
//Simpan gambar dalam ukuran sebenarnya
51+
52-
move_uploaded_file($_FILES["image"]["tmp_name"], $vfile_upload);
52+
	header('location:admin.php?page=slide');exit();
53
}
54-
//identitas file asli
54+
55-
$im_src = imagecreatefromjpeg($vfile_upload);
55+
56-
$src_width = imageSX($im_src);
56+
57-
$src_height = imageSY($im_src);
57+
58
	//direktori gambar
59-
//Simpan dalam versi small 1920 pixel
59+
	$vdir_upload = "../images/slider/";
60-
//Set ukuran gambar hasil perubahan
60+
	$vfile_upload = $vdir_upload . $fupload_name;
61-
$dst_width = 1920;
61+
62-
$dst_height = ($dst_width/$src_width)*$src_height;
62+
	//chmod("$vfile_upload", 0644);
63
64-
//proses perubahan ukuran
64+
	//Simpan gambar dalam ukuran sebenarnya
65-
$im = imagecreatetruecolor($dst_width,$dst_height);
65+
	if(copy($_FILES["image"]["tmp_name"], $vfile_upload)){
66-
imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
66+
		//identitas file asli
67
		$im_src = imagecreatefromjpeg($vfile_upload);
68-
//Simpan gambar
68+
		$src_width = imageSX($im_src);
69-
imagejpeg($im,$vdir_upload . "small_" . $fupload_name);
69+
		$src_height = imageSY($im_src);
70
71-
//Hapus gambar di memori komputer
71+
		//Simpan dalam versi small 1920 pixel
72-
imagedestroy($im_src);
72+
		//Set ukuran gambar hasil perubahan
73-
imagedestroy($im);
73+
		$dst_width = 1920;
74
		$dst_height = ($dst_width/$src_width)*$src_height;
75
76
		//proses perubahan ukuran
77
		$im = imagecreatetruecolor($dst_width,$dst_height);
78
		imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
79
80
		//Simpan gambar
81
		imagejpeg($im,$vdir_upload . "small_" . $fupload_name);
82
83
		//Hapus gambar di memori komputer
84
		imagedestroy($im_src);
85
		imagedestroy($im);
86
	
87
	}else{
88
		return false;
89
	}
90
91
}