Example:
| Field | Type | Length | Extra | Primary |
| Id_upload | Int | 3 | Auto_increment | yes |
| Nama_file | Varchar | 100 | | |
| Ukuran | int | 100 | | |
| Deskripsi | text | | | |
| Direktori | varcahr | 100 | | |
Script from upload:
<form enctype="multipart/form-data" method="post" action="upload_1.php">
File yang diupload : <input type="file" name="fupload"><br>
Deskripsi File : <br><textarea name="deskripsi" rows="8" cols="40"></textarea><br>
<input type=submit value=Upload>
</form>
Script upload_1.php
// Read variable location, name & size of the file of the form (fupload)
$lokasi_file = $_FILES['fupload']['tmp_name'];
$nama_file = $_FILES['fupload']['name'];
$ukuran_file = $_FILES['fupload']['size'];
$direktori = "files/$nama_file";
//If the file successfully uploads
if (move_uploaded_file($lokasi_file,"$direktori")){
echo "Nama File : $nama_file berhasil di upload
";
echo "Ukuran File : $ukuran_file bytes";
// Masukkan informasi file ke database
mysql_connect("localhost","root","pajarmaning");
mysql_select_db("db_web");
// Enter information into the database file
$input="INSERT INTO upload_file(nama_file,ukuran_file,deskripsi,direktori)
VALUES('$nama_file','$ukuran_file','$_POST[deskripsi]','$direktori')";
mysql_query($input);
}
else{
echo "File gagal diupload";
}
?>
Description:Move_uploaded_file (file_sumber, file_tujuan) is a function to upload a file.There is also a function copy (file_sumber, file_tujian) and the same function is to upload a file / copy file.
Test:
Click browse to select the file and click upload to upload a file.To ensure the file has been sent will be visible in the folder where you hold the files that have been made previously

0 comments: on "Upload File"
Post a Comment
Terima kasih atas kunjungan anda