MrBrohid123

ProsesUpload

Oct 26th, 2018
12,649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. <?php
  2.    
  3.     $image = base64_decode($_POST['foto']);
  4.     $namaimage =  rand(1, 10000);
  5.     $tanggal = date("Y-m-d");
  6.  
  7.     $nama = "image-".$tanggal.$namaimage;
  8.  
  9.     $targer_dir = "Foto/".$nama.".jpeg";
  10.     if (file_put_contents($targer_dir, $image)) {
  11.         echo json_encode(array('response'=>'Success'));
  12.     }else{
  13.         echo json_encode(array("response" => "Image not uploaded"));
  14.     }
  15.    
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment