form_upload.php
<form enctype="multipart/form-data"
method="POST" action="upload_1.php">
file yang di uplod: <input type="file" name="fupload"><br>
deskripsi file: <br>
<textarea name="deskripsi" rows="8" cols="40"></textarea><br>
<input type=submit value=upload>
</form>
upload_1.php
<?php
//variabel lokasi,nama & ukuran file dari form (fupload)
$lokasi_file= $_FILES['fupload']['tmp_name'];
$nama_file = $_FILES['fupload']['name'];
$ukuran_file= $_FILES['fupload']['size'];
$direktori = "files/$nama_file";
//apabila file berhasil di upload
if (move_uploaded_file ($lokasi_file,"$direktori")){
echo "Nama File : <b>$nama_file</b> sukses di upload <br>";
echo "Ukuran File : <b>$ukuran_file</b> bytes";
//masukkan informasi file ke database
mysql_connect("localhost","root");
mysql_select_db("mahasiswa");
mysql_query("INSERT INTO tabel upload_file(nama_file,Ukuran_file,Deskripsi,Direktori) VALUES('$nama_file','$ukuran_file','$_POST[deskripsi]','$direktori')");
}
else{
echo "file gagal diupload";
}
?>
<form enctype="multipart/form-data"
method="POST" action="upload_1.php">
file yang di uplod: <input type="file" name="fupload"><br>
deskripsi file: <br>
<textarea name="deskripsi" rows="8" cols="40"></textarea><br>
<input type=submit value=upload>
</form>
upload_1.php
<?php
//variabel lokasi,nama & ukuran file dari form (fupload)
$lokasi_file= $_FILES['fupload']['tmp_name'];
$nama_file = $_FILES['fupload']['name'];
$ukuran_file= $_FILES['fupload']['size'];
$direktori = "files/$nama_file";
//apabila file berhasil di upload
if (move_uploaded_file ($lokasi_file,"$direktori")){
echo "Nama File : <b>$nama_file</b> sukses di upload <br>";
echo "Ukuran File : <b>$ukuran_file</b> bytes";
//masukkan informasi file ke database
mysql_connect("localhost","root");
mysql_select_db("mahasiswa");
mysql_query("INSERT INTO tabel upload_file(nama_file,Ukuran_file,Deskripsi,Direktori) VALUES('$nama_file','$ukuran_file','$_POST[deskripsi]','$direktori')");
}
else{
echo "file gagal diupload";
}
?>
0 komentar:
Posting Komentar