ahmfarisi

upload.php

May 19th, 2022
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. $image = $_FILES['file']['tmp_name'];
  4. $imagename = $_FILES['file']['name'];
  5.  
  6. $file_path = $_SERVER['DOCUMENT_ROOT'] . '/foto';
  7.  
  8. $response = array();
  9.  
  10. if (!file_exists($file_path)) {
  11.     mkdir($file_path, 0777, true);
  12. }
  13.  
  14. if(!$image){
  15.         $response["kode"] = 0;
  16.         $response["pesan"] = "Gambar Tidak Ditemukan";
  17. }
  18. else{
  19.     if(move_uploaded_file($image, $file_path.'/'.$imagename)){
  20.         $response["kode"] = 1;
  21.         $response["pesan"] = "Gambar Sukses Diupload";
  22.     }
  23. }
  24.  
  25. echo json_encode($response);
Add Comment
Please, Sign In to add comment