The virtual host purchased by our grassroots webmasters often has a limit on the number of files, and a large number of small files occupy a lot of resources. Some brothers in the outdated essence area also recommended Douban's solution, but they must have host permissions. I can only install another idea and use php+SQLite to solve the problem. After I tested it, it is feasible and I recommend it to everyone now.
Now make the code public:
Create database file: php1.php
Copy the code The code is as follows:
$db = new SQLite3('mysqlitedb.db');
//Get the file binary stream
$filename = "http://www.jb51.net/logo.gif" ;
$handle = fopen($filename, "r");
$contents = fread($handle, filesize ($filename));
fclose($handle);
//Create Data table
$db->exec('CREATE TABLE person (idnum TEXT,name TEXT,photo BLOB)');
$stmt = $db->prepare("INSERT INTO person VALUES ('41042119720101001X', '张三',?)");
$stmt->bindValue(1, $contents, SQLITE3_BLOB);
$stmt->execute();
Read data file: php2.php
Copy code The code is as follows:
$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();
}
ANSYS Tutorial
http://www.bkjia.com/PHPjc/322429.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/322429.html
TechArticle
The virtual hosts purchased by our grassroots webmasters often have restrictions on the number of files. A large number of small files occupy a lot of resources and are outdated. Some brothers in the district also recommended Douban’s solution, but it requires a host...