what sapp bambang ini adalah source code proses upload photo yang di miliki KING sulaiman tetapi sayangnya tidak memiliki validasi ukuran gambar tetapi memiliki tipe format gambar seperti PNG JPG dan JPEG.
<?php
if(isset($_POST['Submit'])) {
$no_plat = $_POST['no_plat'];
$nm_mobil = $_POST['nm_mobil'];
$thn = $_POST['thn'];
$merek = $_POST['merek'];
$digunakan = $_POST['digunakan'];
$keadaan = $_POST['keadaan'];
$status = $_POST['status'];
$nama_file = $_FILES['gambar']['name'];
$tmp_file = $_FILES['gambar']['tmp_name'];
$type_file = $_FILES['gambar']['type'];
// include database connection file
include_once("koneksi.php");
if ($nama_file == "") {
$query = mysqli_query($koneksi, "INSERT INTO data_mobil(no_plat,nm_mobil,thn,merek,digunakan,keadaan,status) VALUES('$no_plat','$nm_mobil', '$thn', '$merek', '$digunakan', '$keadaan','$status')");
if ($query) {
echo '<script>alert("Data Berhasil Ditambah");
window.location="data_admin.php" </script>';
} else {
echo '<script language="javascript">alert("Data Gagal Ditambah!")
window.history.go(-1);</script>';
}
} else {
if ($type_file == "image/png" or $type_file == "image/jpg" or $type_file == "image/jpeg") {
$upload = move_uploaded_file($tmp_file, "../../gambar/$nama_file");
if ($upload) {
$query = mysqli_query($koneksi, "INSERT INTO `data_mobil` (`no_plat`, `nm_mobil`, `thn`, `merek`, `digunakan`, `keadaan`, `status`, `gambar`) VALUES ('$no_plat', '$nm_mobil', '$thn', '$merek', '$digunakan', '$keadaan', '$status', '$nama_file');");
if ($query) {
echo '<script>alert("Data Berhasil Ditambah");
window.location="data_mobil.php" </script>';
} else {
echo '<script language="javascript">alert("Data Gagal Ditambah!")
window.history.go(-1);</script>';
}
}
else {
echo '<script language="javascript">alert("Gambar Gagal DiUpload!")
window.history.go(-1);</script>';
}
} else {
echo '<script language="javascript">alert("Jenis File Tidak Didukung!")
window.history.go(-1);</script>';
}
}
} else {
echo '<script language="javascript">alert("Data Gagal Ditambah!")
window.history.go(-1);</script>';
}
?>
Bagikan
source code proses upload photo
4/
5
Oleh
Unknown