if (!empty($lokasi_file)) {
            if ($tipe_file != "image/jpeg" and $tipe_file != "image/pjpeg") {
                echo "<script>window.alert('Upload Gagal, Pastikan File yang di Upload bertipe *.JPG');\n        window.location=('../../media.php?module=banner')</script>";
            } else {
                UploadBanner($nama_file);
                mysql_query("INSERT INTO banner(judul,\n                                    url,\n                                    tgl_posting,\n                                    gambar) \n                            VALUES('{$_POST['judul']}',\n                                   '{$_POST['url']}',\n                                   '{$tgl_sekarang}',\n                                   '{$nama_file}')");
                header('location:../../media.php?module=' . $module);
            }
        } else {
            mysql_query("INSERT INTO banner(judul,\n                                    tgl_posting,\n                                    url) \n                            VALUES('{$_POST['judul']}',\n                                   '{$tgl_sekarang}',\n                                   '{$_POST['url']}')");
            header('location:../../media.php?module=' . $module);
        }
    } elseif ($module == 'banner' and $act == 'update') {
        $lokasi_file = $_FILES['fupload']['tmp_name'];
        $tipe_file = $_FILES['fupload']['type'];
        $nama_file = $_FILES['fupload']['name'];
        // Apabila gambar tidak diganti
        if (empty($lokasi_file)) {
            mysql_query("UPDATE banner SET judul     = '{$_POST['judul']}',\n                                   url       = '{$_POST['url']}'\n                             WHERE id_banner = '{$_POST['id']}'");
            header('location:../../media.php?module=' . $module);
        } else {
            if ($tipe_file != "image/jpeg" and $tipe_file != "image/pjpeg") {
                echo "<script>window.alert('Upload Gagal, Pastikan File yang di Upload bertipe *.JPG');\n        window.location=('../../media.php?module=banner')</script>";
            } else {
                UploadBanner($nama_file);
                mysql_query("UPDATE banner SET judul     = '{$_POST['judul']}',\n                                   url       = '{$_POST['url']}',\n                                   gambar    = '{$nama_file}'   \n                             WHERE id_banner = '{$_POST['id']}'");
                header('location:../../media.php?module=' . $module);
            }
        }
    }
}
Ejemplo n.º 2
0
    }
    header('location:../../media.php?module=' . $module);
} elseif ($module == 'kurir' and $act == 'input') {
    $lokasi_file = $_FILES['fupload']['tmp_name'];
    $nama_file = $_FILES['fupload']['name'];
    $acak = rand(00, 999999);
    $nama_file_unik = $acak . $nama_file;
    // Apabila ada gambar yang diupload
    if (!empty($lokasi_file)) {
        UploadBanner($nama_file_unik);
        mysql_query("INSERT INTO mod_kurir(nama_kurir,\n                                    url,\n                                    gambar) \n                            VALUES('{$_POST['nama']}',\n                                  '{$_POST['url']}',\n                                   '{$nama_file_unik}')");
    }
    header('location:../../media.php?module=' . $module);
} elseif ($module == 'kurir' and $act == 'update') {
    $lokasi_file = $_FILES['fupload']['tmp_name'];
    $nama_file = $_FILES['fupload']['name'];
    $acak = rand(00, 999999);
    $nama_file_unik = $acak . $nama_file;
    // Apabila gambar tidak diganti
    if (empty($lokasi_file)) {
        mysql_query("UPDATE mod_kurir SET nama_kurir  ='{$_POST['nama']}',\n                                      url = '{$_POST['url']}'\n                             WHERE id_kurir = '{$_POST['id']}'");
    } else {
        UploadBanner($nama_file_unik);
        $file = mysql_fetch_array(mysql_query("SELECT gambar FROM mod_kurir WHERE id_kurir='{$_POST['id']}'"));
        //hapus foto dari folder
        unlink("../../../joimg/banner/{$file['gambar']}");
        unlink("../../../joimg/banner/s_{$file['gambar']}");
        mysql_query("UPDATE mod_kurir SET nama_kurir     = '{$_POST['nama']}',\n                                    url = '{$_POST['url']}',\n                                   gambar    = '{$nama_file_unik}'   \n                             WHERE id_kurir = '{$_POST['id']}'");
    }
    header('location:../../media.php?module=' . $module);
}