We grassroots owners buy the virtual host often have a file limit, a large number of small files occupy a large number of resources, the outdated essence area also has a brother recommended watercress solution, but to have host permissions. Can only install ideas, using Php+sqlite to solve the problem, after my test, practical, now recommended to everyone.
Now expose the code:
To create a database file: php1.php
Copy Code code as follows:
$db = new SQLite3 (' mysqlitedb.db ');
Get file 2 feed stream
$filename = "Yun_qi_img/logo.gif";
$handle = fopen ($filename, "R");
$contents = Fread ($handle, FileSize ($filename));
Fclose ($handle);
Creating data Tables
$db->exec (' CREATE TABLE person (idnum text,name text,photo BLOB) ');
$stmt = $db->prepare ("INSERT into person VALUES (' 41042119720101001X ', ' John ',?)");
$stmt->bindvalue (1, $contents, Sqlite3_blob);
$stmt->execute ();
Read Data file: php2.php
Copy Code code 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 Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv=" Content-type " Content= "text/html; Charset=utf-8 "/>
<title>ansys Tutorials </title>
<body>
</body>