You are on page 1of 1

UPLOAD.

PHP

<?php
 $lokasi = "picture/";
 $nama_file = $lokasi. basename($_FILES["FileToUpload"]["name"]);
 $upload_sukses = 1;

 if ($upload_sukses==0) {
     echo "Maaf, file belum teruplod";
 }else {
     if (move_uploaded_file($_FILES["FileToUpload"]["tmp_name"],$nama_file)) {
         echo "File " . basename($_FILES["FileToUpload"]["name"]) . " di uploa
d";
     }else {
         echo "Maaf, mungkin ada kesalahan dalam proses upload file anda";
     }
 }
?>

FORM_UPLOAD.PHP

!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="upload.php" method="post" enctype="multipart/form-data">
    Pilih gambar : <input type="file" name="FileToUpload">
    <input type="submit" name= "Kirim" value="Upload Gambar">

    </form>
</body>
</html>

You might also like