阅读" /"没有改成" \ /"在PHP中

时间:2016-04-01 09:40:12

标签: php image base64 hosting encode

我一直试图从php读取编码图像,我的PHP代码是

<?php

$configs = include('config.php');

$dbhost = $configs['host'];
$dbuser = $configs['user'];
$dbpass = $configs['pass'];
$dbname = $configs['dbname'];
$tblbarang = 'tbl_barang';

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

try
{
    mysql_connect($dbhost,$dbuser,$dbpass);
    mysql_select_db($dbname);


    {
        if(isset($_GET["id_penjual"]))
        {
            $id_penjual=$_GET["id_penjual"];

            $querysel = "SELECT b.id_barang, b.nama_barang, b.harga, b.stok, b.deskripsi_barang, b.id_kategori, b.id_penjual, b.id_image, i.nama, i.image FROM tbl_barang b join tbl_image i on b.id_image=i.id_image WHERE id_penjual =$id_penjual";
            $query = '';
            $querysel.=$query;
            $result = mysql_query($querysel);
            header('Content-Type: text/html; charset=utf-8');
            while ($row = mysql_fetch_array($result))
            {
                $temp = array();
                $temp["id_barang"] = $row["id_barang"];
                $temp["nama_barang"] = $row["nama_barang"];
                $temp["harga"] = $row["harga"];
                $temp["stok"] = $row["stok"];
                $temp["deskripsi_barang"] = $row["deskripsi_barang"];
                $temp["id_kategori"] = $row["id_kategori"];
                $temp["id_penjual"] = $row["id_penjual"];
                $temp["id_image"] = $row["id_image"];
                $temp["nama"] = $row["nama"];
                $temp["image"] = $row["image"];

                array_push($response["result"],$temp);

            }
                $response["message"]=0;
        }
        else
            $response["message"]=1;
    }
}

catch(Exception $e)
{
    $response["message"]=0;
}

$response = json_encode($response);
echo $response;

但是当我将图像的编码代码插入数据库时​​,结果是

http://i.stack.imgur.com/MSckI.jpg

我无法读取图像,因为当编码图像有一个&#34; \&#34;它将转向&#34; /&#34;当我从Web服务访问数据库时

请帮助我,谢谢

0 个答案:

没有答案