Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // code A
- //include("fungsi_koneksi.php");
- $host="localhost";
- $user="root";
- $pass="";
- $db="work_mujur";
- $mysqli = new mysqli($host, $user, $pass, $db);
- if (mysqli_connect_errno()) {
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }
- else{
- //echo 'Koneksi berhasil';
- // printf("<br/>Host information: %s\n", $mysqli-> host_info);
- }
- // end of code A
- // code B
- $lokasi_file = $_FILES['pp']['tmp_name'];
- $tipe_file = $_FILES['pp']['type'];
- $nama_file = $_FILES['pp']['name'];
- $direktori = "image/$nama_file";
- // end of code B
- //if (!empty($lokasi_file)) {
- $aksi=upload($lokasi_file,$direktori);
- if (!$aksi) {
- echo "maaf gagal memasukan gambar";exit();
- }
- // code C
- //$koneksi = koneksi_db();
- $sql = "insert into dtimage values (null,'$nama_file')";
- //$aksi = mysql_query($sql,$koneksi);
- $q=$mysqli->query($sql);
- if(!$q){
- echo 'Wrong SQL: ' . $sql . ' Error: ' . $conn->error ;
- exit();
- }
- // end of code C
- // code D
- //if (!$aksi) {
- //echo "maaf gagal memasukan gambar";
- //}else{
- echo "gambar berhasil di upload<br>";
- echo "untuk melihatnya silakan klik <a href='view_image.php'>Link ini</a>";
- //}
- // end of code D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement