Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use php+mysql to save and output files (transfer)

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Use php+mysql to save and output the file (transfer) [@ more@] after the local file is uploaded to the server, the server script saves the file in two ways, one is to save the file to a specific directory of the machine, but there are many inconveniences such as file renaming, some programs automatically change the file name, add the name to the upload time and other methods to ensure the uniqueness of the file name In this way, the original name of the file is lost, and there are many difficulties in querying specific file information through the file name, which is not conducive to the unified management of the file. One is to save the document to the database and make use of the powerful function of the database, which can easily realize all kinds of operations of the file. The second method is adopted in this paper. This set of programs demonstrates how to upload a file from a hard disk to the server's database through a web page, and read out the contents of the file. Instructions: there are 5 programs in total. The explanation is as follows: 1. File.sql-the structure of the database table to be used in this program [Note: the database uses test] 2. Upload.php-upload form 3. Submit.php-upload processor 4. Show_info.php-display partially uploaded file information 5. Show_add.php-display [download] file / / (1) file.sql-/ / briefly describe the database structure for saving the basic information of the uploaded file Note here that the fields that save the contents of the file use the longtext type because the normal blob type stores up to 64k bytes. In addition, the default configuration of general php is 2m for uploading files. If the uploaded files are particularly large, don't forget to adjust the php.ini settings. / / File source code create table receive (id int not null auto_increment, # primary key, auto-accumulating file_data longblob, # file content file_type varchar, # file type file_name varchar, # file name file_size int # File size primary key (id) # key) / (2) upload.php-- / / brief description of the upload interface The user selects the file and then submits it to submit.php for processing. It is worth noting that a hidden range of max_file_size can be set by setting its value to limit the size of the uploaded file. / / Select the program source code to upload the file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report