The number of files on the virtual hosts purchased by our grassroots webmaster is usually limited. A large number of small files occupy a large amount of resources. In the outdated vertices, Douban is recommended for solutions, but the host permission is required. I can only install another idea and use PHP + SQLite to solve the problem. After my tests, it is practical and recommended to you now.
Public nowCode:
Create a database file: php1.phpCopy codeThe Code is as follows: $ db = new sqlite3 ('mysqlitedb. db ');
// Obtain the binary stream of a file
$ Filename = "http://www.jb51.net/logo.gif ";
$ Handle = fopen ($ filename, "R ");
$ Contents = fread ($ handle, filesize ($ filename ));
Fclose ($ handle );
// Create a data table
$ Db-> exec ('create table person (idnum text, Name text, photo BLOB )');
$ Stmt = $ db-> prepare ("insert into person values ('201742119720101001x ', 'zhangsan ',?) ");
$ Stmt-> bindvalue (1, $ contents, sqlite3_blob );
$ Stmt-> execute ();
Read data files: php2.phpCopy codeThe Code is as follows: <? PHP
$ PDO = new sqlite3 ('mysqlitedb. db ');
$ Results = $ PdO-> query ('select * From person ');
While ($ ROW = $ results-> fetcharray ()){
Ob_start ();
Header ("Content-Type: image/jpg ");
Echo $ row ['photo'];
Ob_end_flush ();
}
?>
Web page reference:Copy codeThe Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> ANSYS tutorial </title>
</Head>
<Body>
</Body>
</Html>