Source code php upload file, upload.php
______________START___________ ______
//terima file dari user
$fname = $_FILES['gambar']['name']; //nama filenya
$ftype = $_FILES['gambar']['type']; //tipe filenya
$fsize = $_FILES['gambar']['size']; //ukuran filenya
$ftemp = $_FILES['gambar']['tmp_name']; //direktori penyimpanan sementara file
$error = "";
if(empty($fname))
$error = "Nama file tidak boleh kosong.
";
if(!$ftype == "image/jpeg" OR !$ftype == "image/pjpeg" OR !$ftype == "image/x-png" OR !$ftype == "image/gif")
$error .= "File yang diupload harus berupa gambar dengan format JPEG/PJPEG/PNG/GIF.
";
@ $baca_dir = opendir('images/');
if(!$baca_dir)
{
mkdir('images/', 0777);
}
if(!copy($ftemp, "images/$fname"))
$error .= "Tidak bisa memindahkan file gambar ke direktori.
";
if($error == "")
echo "File berhasil diupload";
else
echo $error;
?>
_______________END____________ ______
============================
______________________________ ______
Source code HTML upload file, index.html
______________START_________________
File Upload
File Upload...
Upload file ini:
_______________END__________________
File Upload
File Upload...
_______________END____________ ______
______________START_________________
File Upload
File Upload...
Upload file ini:
_______________END__________________
No comments:
Post a Comment