Bagaimana Cara mengupload Picture dengan beberapa file yang berbeda?

Saya sedang membuat mencoba membuat file dengna mengupload beberapa gambar kedalam sebuat file dan membuatnya muncul di tabe yang di panggil setelah saya coba file tidak muncul dan hanya memberikan pemberitahuan bahwa file bukan PNG/JPG walaupun file tersebut sudah jpg dan png. mohon bantuannya qwq)

//menambah foto
if(isset($_POST['addpicture'])){
    $no_polisi = $_POST['no_polisi'];
    $foto_mobil = $_POST['foto_mobil'];
    $foto_norangka = $_POST['foto_norangka'];
    $foto_nomesin = $_POST['foto_nomesin'];
    $foto_stnk = $_POST['foto_stnk'];
    $foto_bpkb = $_POST['foto_bpkb'];

    //Buat Gambar
    $allowed_extention = array('png', 'jpg');
    $nama = $_FILES['files']['name']; //ambil nama gambar
    $dot = explode('.',$nama);
    $ekstensi = strtolower(end($dot)); //ambil ekstensi
    $ukuran = $_FILES['files']['size']; //ambil size file
    $file_temp = $_FILES['files']['temp_name']; //ambil lokasi filenya

    //penamaan file -> enkripsi
    $image = md5(uniqid($nama,true) . time()).'.'.$ekstensi;//gabung nama enkripsi dengan ekstensinya

    $cekdata = mysqli_query($conn,"select * from detail where no_polisi = '$no_polisi'");
    $hitungdata = mysqli_num_rows($cekdata);

    if($hitungdata < 1){

        if(in_array($ekstensi, $allowed_extention) === true){
            if($ukuran < 15000000){
                move_uploaded_file($file_temp, 'image/'.$foto_mobil, 'image/'.$foto_norangka, 'image/'.$foto_nomesin, 'image/'.$foto_bpkb);
                $addtotable = mysqli_query($conn, "insert into detail (no_polisi, foto_mobil, foto_norangka, foto_nomesin, foto_stnk, foto_bpkb)
                values ('$no_polisi', '$foto_mobil', '$foto_norangka', '$foto_nomesin', '$foto_stnk', '$foto_bpkb')");
                if($addtotable){
                    header('location:detail.php');
                }else{
                    echo'gagal';
                    header('location:detail.php');
                }
            }else{
                //Kalau Filenya lebih dari 15mb
                echo '
                <script>
                    alert("Ukuran terlalu besar, harus di bawah 15 mb);
                    window.location.href="detail.php";
                </script>
                ';
            }
        }else{
            //Kalau filenya bukan png atau jpg
            echo '
                <script>
                    alert("File bukan PNG/JPG ");
                    window.location.href="detail.php";
                </script>
            ';
        }
}else {
    //jika udh ada
    echo '
    <script>
        alert("No Polisi Sudah tersedia");
        window.location.href="detail.php";
    </script>
    ';
    }
}
avatar zenkuromusicandpicturefusion
@zenkuromusicandpicturefusion

2 Kontribusi 0 Poin

Diperbarui 2 tahun yang lalu

2 Jawaban:

<div>coba ditambahkan opsi 'jpeg' nya juga<br>kadang ada file jpg namun saat di cek meta nya ternyata jpeg</div>

avatar insanz01
@insanz01

90 Kontribusi 56 Poin

Dipost 2 tahun yang lalu

<div>masih tidak bisa kak, saya sudah coba tapi hasilnya seperti ini <figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image.png&quot;,&quot;filesize&quot;:41131,&quot;height&quot;:637,&quot;url&quot;:&quot;https://i.ibb.co/L1BKSHf/image.png&quot;,&quot;width&quot;:1234}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/L1BKSHf/image.png" width="1234" height="637"><figcaption class="attachment__caption"><span class="attachment__name">image.png</span></figcaption></figure>tetapi pas saya pencet close ada errornya, tapi saya cuma bisa liat errorny kayak cum satu framse sja abis itu balik ke page sebelumnya</div>

avatar zenkuromusicandpicturefusion
@zenkuromusicandpicturefusion

2 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

Login untuk ikut Jawaban