Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "../config/koneksi.php";
- extract($_POST);
- $newDate = date("Y-m-d", strtotime($_POST['tanggal']));
- $list = array("jpg", "png","jpeg","gif");
- $nama_file=$_FILES['datafile']['name'];
- $pecah = explode(".", $nama_file);
- $ekstensi = $pecah[1];
- $ukuran=$_FILES['datafile']['size'];
- $uploaddir='../links/';
- $alamatfile=$uploaddir.$nama_file;
- $sql=mysql_query("SELECT * FROM `tabel_link` WHERE id_link") or die('Error, query failed. ' . mysql_error());
- $ada=mysql_fetch_array($sql);
- $gambar=$ada['gambar'];
- $imageInformation = getimagesize($_FILES['datafile']['tmp_name']);
- $imageWidth = $imageInformation[0]; //Contains the Width of the Image
- $imageHeight = $imageInformation[1]; //Contains the Height of the Image
- $width=380;
- $height=265;
- if (($imageWidth != $width) && ($imageHeight!=$height))
- {
- echo "<script>
- alert ('Perhatikan ukuran');
- window.location='tambah_artikel.php';
- </script>";
- }
- //di bagian ini kok gak runing ya bang
- if ($nama_file==$gambar)
- {
- echo "<script>
- alert ('Nama file sama, harap ganti');
- window.location='tambah_links.php';
- </script>";
- die();
- }else{
- if (in_array($ekstensi, $list))
- {
- {if (move_uploaded_file($_FILES['datafile']['tmp_name'],$alamatfile)){
- $sql1=mysql_query("INSERT INTO `cms`.`tabel_link` (`id_link`, `judul`, `tgl`, `gambar`,
- `link`, `artikel`, `status`)
- VALUES (NULL, '$judul', '$newDate', '$nama_file', '$link', '$artikel', '$stat')");
- if ($sql1){
- echo "<script>
- alert('upload OK');
- window.location='master_links.php';
- </script>";
- }else{
- die(mysql_error()."<br/>$sql");
- }
- }else{
- die('tidak bisa move file');
- }
- }
- }else{
- echo "<script>
- alert ('Format harus jpg atau png');
- window.location='tambah_links.php';
- </script>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement