Saya telah berhasil membuat upload file, sekarang saya akan membuat kebalikannya, yaitu download file. Sederhanya, aplikasi download file menyediakan link terhadap file yang akan kita download, dimana link itu di klik makan terjadilah proses download. Code Candil Kuya - Aplikasi Upload File PHP dan Mysql Berbasis php memiliki tampilan dan fungsi yang sederhana sehingga dapat berjalan dengan baik, karena program ini sangat cocok sebagai referensi pembelajaran menggunakan php untuk mengembangkan Source Code Aplikasi Upload File PHP dan Mysql. Source Code Aplikasi Upload File PHP dan Mysql berbasis web ini masih memerlukan pengembangan lebih lanjut, sehingga kami dapat mengembangkan kembali kode sumber aplikasi ini dari front end dan menambahkan fitur-fitur yang belum ada, sehingga menjadi aplikasi fungsional berbasis web yang lebih baik. Dan manfaatkan aplikasi tersebut. Source Code Aplikasi Upload File PHP dan MysqlAnda dapat mengembangkan kembali source code aplikasi ini baik dari tampilan maupun menambahkan fitur yang belum ada, sehingga menjadi sebuah program aplikasi berbasis web yang lebih baik lagi, baik itu pada sisi fiturnya ataupun didalam penggunaan dari program tersebut. Tentunya program ini juga bisa dijadikan atau dijadikan referensi untuk Belajar Menjadi Seorang Programmer Atau Bisa Dijadikan Untuk Refferensi Tugas Akhir Kuliah. tentunya harus terlebih dahulu dimodifikasi, dikembangkan dan disesuaikan, serta disesuaikan dengan kemampuan masing-masing sobat.Hal ini dilakukan dengan memperhatikan lisensi atau hak cipta. Realisasi sangat penting. Mengacu pada pengembang atau Pembuat. Features
DetailNamaUpload File PHPLisensiOpen SourceAuthorUnknownUser:adminPassword:adminJika Terjadi kesalahan saat loggin Silahakan cek database di phpmyadmin atau Bisa cek video tutorial di youtube chanel CANDIL CODE DownloadSilahkan download Source Code Aplikasi Upload File PHP dan Mysql di bawah ini. Dukung Juga Youtube Channel CANDIL CODE Dengan Cara Subscribe dan aktifkan lonceng Notifikasinya Agar Anda Bisa Mendapatkan Pemberitahuan Apdate Dari Setiap Video Terbaru Yang Saya Upload, jika link yang mati harap silahkan tulis di kolom komentar agar Saya dapat segera memperbaikinya. terimakasih! Semoga Bermanfaat. Password PenutupSaya membagikan source code aplikasi ini hanya untuk tujuan pengujian dan pendidikan. Jika Ada Pihak Yang Merasa Di Rugikan, Silahkan kirimkan email kepada Saya Melalui Halaman Kontak Saya akan menghapusnya sesegera mungkin. This tutorial demonstrates how you can upload files of various formats including .zip, .pdf, .docx, .ppt, as well as image files through a form using PHP to be stored in a folder on our server. We will also record the name of the uploaded files and related info such as the file name, size, and the number of downloads in a database table. Create a new PHP project folder and call it file-upload-download. Create a subfolder inside this folder called uploads (this is where our uploaded files will be stored), and a file called index.php. index.php is where we will create our file upload form. Open it and put this code inside it: index.php:
It's a very simple form that takes just the input field for our file and an upload button. In the head section, we are linking to our style.css file to provide some styling to our form. Create that file in the root of our application and add this CSS code to it: style.css:
At the top of index.php, we are including filesLogic.php file. This is the file that contains all the logic of receiving our submitted file and saving it to the uploads folder as well as storing the file information in the database. Let's create this file now. filesLogic.php:
At the top of this file, we are connecting to a database but we've not yet created it yet. Let's do that now. Create a new database called file-management. Under this database, create a table called files and give it the following fields.
Now open index.php file in your browser. For me, I'll head over to http://localhost/file-upload-download/download.php. Click on the file input field and select any file from your machine to upload.
Having selected your file, you can click on the upload button. If everything goes well, your file will be uploaded to the uploads folder in your project and a new record will be created in the files table in the database containing the filename, size, and downloads count. Now our file has been uploaded. You can check your uploads folder and database table to confirm that it was successful. Let's display it so that the user can view it and click on it to download it. First, we need to fetch the file info from the database. Open filesLogic.php and add these 3 lines of code just below the line where we connect to the database:
This selects all files information from the database and sets it to an array variable called $files. Now create a file called downloads.php in the root folder of our application and add this code inside it: downloads.php:
Now on this page, the files information from the database are listed each along with its size in KB and number of downloads. There is also a download button against each file. What remains now is the code that actually downloads the file from our uploads folder. Let's write the code right away. Open filesLogic.php again and add this code at the end of the file: filesLogic.php:
When we were listing the files, each download button (or rather, download link) had a parameter called file_id attached to it. So when you click on the download link of a file, that file's id is sent to the filesLogic.php page and is grabbed by this piece of code we just added now. The code then fetches that particular file info from the database using the file_id parameter and then stores the file info in a variable called $file. Using PHP's file_exists() method with the full path to our file as an argument we check that the file actually exists in our uploads folder. Then we proceed to set some headers and finally respond with the file to the user using the readFile() function in PHP. After the file is downloaded, we update the downloads count for that particular file in the database. ConclusionThat's about it with file upload and download. You can further customize it to build cool PHP applications. Thanks very much for following. Let me know what you think about this article in the comments section below, if you please. |