我有一个包含两个字段的表:
1)文件夹:带有文件夹路径;
2)name:png文件的名称
使用php代码,我需要获取所有完整路径(例如frames/1.png和frames/2.png),使用此路径,我需要获取真实图像并将它们插入到数组中,就好像它们全部一样 Blob 。
目前我使用这个代码,但有了这个我只有路径,而不是真实的图像。你能帮我吗?
<?php
require("db.php");
session_start();
$sql = "SELECT concat('C:/wamp/www/Tecnitalia_Optic/app/webroot/img/',folder, thumb) as mini FROM frames ";
$result = array();
if ($resultdb = $mysqli->query($sql)) {
while($record = $resultdb->fetch_assoc()) {
array_push($result, $record);
}
$resultdb->close();
}
//send back information to extjs
echo json_encode(array(
"success" => $mysqli->connect_errno == 0,
"data" => $result
));
/* close connection */
$mysqli->close();
?>
最佳答案
<?php
require("db.php");
session_start();
$sql = "SELECT concat('C:/wamp/www/Tecnitalia_Optic/app/webroot/img/',folder, thumb) as mini FROM frames ";
$result = array();
if ($resultdb = $mysqli->query($sql)) {
while($record = $resultdb->fetch_assoc()) {
array_push($result, file_get_contents($record['mini']));
}
$resultdb->close();
}
//send back information to extjs
echo json_encode(array(
"success" => $mysqli->connect_errno == 0,
"data" => $result
));
/* close connection */
$mysqli->close();
参见:http://www.php.net/manual/fr/function.file-get-contents.php
关于php - 从 PHP 中的字符串打印文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24512065/