Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. <?php
  2. include "config.php";
  3. if(isset($_POST['Simpan']))
  4. { $fotokode = $_POST['inputkode'];
  5. $fotonama= $_POST['inputnama'];
  6. $kategorikode = $_POST['kategorikode'];
  7.  
  8. $filesize = $_FILES['foto']['size'];
  9. if($filesize <= 1000000) {
  10. $fotonama = $_FILES['foto']['name']; /** untuk menampung data foto atau gambar, menyimpan nama file ke variabel **/
  11. $namaekstensi = pathinfo($fotonama, PATHINFO_EXTENSIONS);
  12.  
  13. if($namaekstensi == "jpg" or $namaekstensi == "pdf"){
  14. $file_tmp = $_FILES["foto"]["tmp_name"];
  15. move_uploaded_file($file_tmp, 'iconfoto/'.$fotonama); /** untuk upload file gambarnya ke direktori iconfoto**/
  16.  
  17. mysqli_query($connection, "INSERT INTO editfoto VALUES ('$fotokode','$fotonama','$kategorikode')");
  18. header("location:i.php");
  19. }
  20.  
  21. }
  22.  
  23.  
  24. }
  25.  
  26. $kategoriquery = mysqli_query($connection, "SELECT * FROM kategoriwisata ORDER BY kategoriKODE ASC");
  27. ?>
  28.  
  29. <form method="POST" enctype="multipart/form-data">
  30. Kode Foto: <input type="text" name="inputkode"><br>
  31. Nama File: <input type="text" name="inputnama"><br>
  32. Gambar: <input type="file" name="foto"><br>
  33. <select name="kategorikode">
  34. <option value="kategorikode"></option>
  35. <?php if (mysqli_num_rows($kategoriquery) > 0) {?>
  36. <?php while($row=mysqli_fetch_array($kategoriquery)) {?>
  37. <option> <?php echo $row["kategoriKODE"] ?>
  38. <?php echo $row["kategoriNAMA"] ?>
  39. </option>
  40. <?php }?>
  41. <?php }?>
  42. </select>
  43.  
  44. <input type="submit" class="btn btn-primary" value="Simpan" name="Simpan">
  45. <input type="reset" class="btn btn-success" value="Batal" name="Batal">
  46. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement