Saturday 25 April 2015

Skrip/Code PHP: Input File 3


<form enctype="multipart/form-data" action="<?php $PHP_SELF; ?>" method="POST">
    Send this file: <input name="userfile" type="file">
    <input type="submit" value="Send File">
</form>

<?php
$folder = "upload/";
$namafile=$_FILES["userfile"]["name"];
$filetemp=$_FILES["userfile"]["tmp_name"];
$path = $folder.basename($namafile);
if($_SERVER["REQUEST_METHOD"]=="POST")
{
      if(!is_dir($folder))
      {
            mkdir($folder);
      }
     
      if((isset($namafile)) && ($namafile != "")){
            $uploadfile=(file_exists($folder.$namafile))?$folder."copy of ".$namafile:$folder.$namafile;
            move_uploaded_file($filetemp, $uploadfile);
            if(chmod($uploadfile, 0775)){
                  echo "File berhasil diupload.\n";
            } else{
                  echo "File belum diambil!\n";
            }
      }
}

?>

Related Posts

Skrip/Code PHP: Input File 3
4/ 5
Oleh

Subscribe via email

Like the post above? Please subscribe to the latest posts directly via email.

2 comments

Tulis comments
avatar
10 October 2018 at 11:17

Terima kasih atas infonya. Dengan moveuploaded file bisa input file(pindahkan file).

Kunjungi blog saya ya: https://tedsu.mahasiswa.atmaluhur.ac.id
dan website kampus saya: http://www.atmaluhur.ac.id

Reply
avatar
20 November 2018 at 10:54

terima kasih mas dengan Skrip/Code PHP bisa input file..

Kunjungi juga website saya di : https://bagussmj.mahasiswa.atmaluhur.ac.id/
dan website kampus saya di : http://www.atmaluhur.ac.id/

Reply