0

SQL Blob と PHP JSON に関して同様の質問があることは知っていますが、コードに従って SQL Blob を JSON として返す方法がわかりません。

Web サイトからデータベースに pdf をアップロードしています。この pdf を Android で表示したいのですが、ご覧のとおり、データ (リンク/ブロブ) は null です。

これは私に返されたものです:

{"file":[{"id":"1","batchid":"121001","name":"dmxsuits.pdf","mime":"application/pdf","size":"263883","data":null,"created":"2013-08-05 03:29:38"}],"success":1}

私のphpコード:

    <?php 

$response = array();

require_once __DIR__ . '/db_connect.php';


$db = new DB_CONNECT();

$result = mysql_query("SELECT * FROM file ORDER BY batchid DESC") or die(mysql_error());

if (mysql_num_rows($result)>0) {

    $response["file"] = array();

    while ($row= mysql_fetch_array($result)) {
        //temp user array
        $pdfFiles = array ();
        $pdfFiles['id'] = $row['id'];
        $pdfFiles['batchid'] = $row['batchid'];
        $pdfFiles['name'] = $row['name'];
        $pdfFiles['mime'] = $row["mime"];
        $pdfFiles['size'] = $row["size"];
        $pdfFiles['data']  = $row['data'];
        $pdfFiles['created'] = $row['created'];


        array_push($response["file"], $pdfFiles);
    }

    //success
    $response["success"] = 1;

    //echoing JSON response
    echo json_encode($response);
} else {

    $response["success"] =0;
    $response["message"] = "No pdf found";

    echo json_encode($response);
}
?>
4

0 に答える 0