我在使用商店阅读我的php文件时遇到问题。我认为问题是php文件中的base64_encode命令。
我解释一下。在我的PHP中,我采用sql代码的路径,之后,通过这条路径,我得到了真实的图像。在我需要将结果保存在一个数组中后,给sencha架构师。
这是PHP代码:
require("db.php");
session_start();
$filepath='';
$sql = "SELECT concat('C:/wamp/www/Tecnitalia_Optic/app/webroot/img/',folder) as Path, thumb as FileName FROM frames ";
$result = array();
if ($resultdb = $mysqli->query($sql)) {
while($record = $resultdb->fetch_array()) {
$filepath = $record['Path'];
$nomeFile = $record['FileName'];
$mimetype = pathinfo($nomeFile, PATHINFO_EXTENSION);
$filedata=filesize($filepath."/".$nomeFile);
header('Content-Type: '.$mimetype);
header('Content-Disposition: attachment; filename="'.$nomeFile.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filedata));
header('Expires: 0');
//readfile($filepath."/".$nomeFile);
$recordnew = readfile($filepath."/".$nomeFile);
$result[] = $recordnew;
}
$resultdb->close();
}
//count total records from table for paging
$sql = "SELECT count(*) as num FROM frames ";
$total = 0;
if ($resultdb = $mysqli->query($sql)) {
$record = $resultdb->fetch_assoc();
$total = $record['num'];
$resultdb->close();
}
//send back information to sencha architect touch
echo json_encode(array(
"success" => $mysqli->connect_errno == 0,
"total" => $total,
"data" => base64_encode($result)
));
/* close connection */
$mysqli->close();
require("db.php");
session_start();
$filepath='';
$sql = "SELECT concat('C:/wamp/www/Tecnitalia_Optic/app/webroot/img/',folder) as Path, thumb as FileName FROM frames ";
$result = array();
if ($resultdb = $mysqli->query($sql)) {
while($record = $resultdb->fetch_array()) {
$filepath = $record['Path'];
$nomeFile = $record['FileName'];
$mimetype = pathinfo($nomeFile, PATHINFO_EXTENSION);
$filedata=filesize($filepath."/".$nomeFile);
header('Content-Type: '.$mimetype);
header('Content-Disposition: attachment; filename="'.$nomeFile.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filedata));
header('Expires: 0');
//readfile($filepath."/".$nomeFile);
$recordnew = readfile($filepath."/".$nomeFile);
$result[] = $recordnew;
}
$resultdb->close();
}
//count total records from table for paging
$sql = "SELECT count(*) as num FROM frames ";
$total = 0;
if ($resultdb = $mysqli->query($sql)) {
$record = $resultdb->fetch_assoc();
$total = $record['num'];
$resultdb->close();
}
//send back information to sencha architect touch
echo json_encode(array(
"success" => $mysqli->connect_errno == 0,
"total" => $total,
"data" => base64_encode($result)
));
/* close connection */
$mysqli->close();
之后,在SA中我创建了一个模型,其中一个字段的类型为auto。在我用模型创建了一个Json Store链接之后,商店就这样说:MyJsonReader无法读取数据。在浏览器中打开:api / frames.php
这是我的sencha架构师代码:
模型和商店
HI Zoltan感谢您的回复。你能用一个例子来解释你说的是什么?我取消了base64_encode命令但是我可以做什么? Inside Architect Touch或在php文件中?
答案 0 :(得分:0)
我认为您不需要对结果进行base64编码,但需要JSON编码来递归编码返回值(即数据par也应该是json编码的值)。