php图像类型blob不会显示

时间:2016-04-01 13:12:50

标签: php mysql

我试图在我的mysql数据库中显示我的blop图像。但我得到的只是一个没有图片的白盒。

PHP代码:

@Injectable()
export class ElasticsearchService {
    private _esUrl = 'http://search:9200';

    constructor(private http: Http) { }

    getHealthString() {
        let healthUrl = '/_cat/health';

        return this.http.get(this._esUrl + healthUrl)
            .map(res => <string>res.text())
            .do(data => console.log(data))
            .catch(this.handleError);
    }
    ...
}

但是当代码运行时,我得到的是:http://imgur.com/nhIO2LQ

任何人都知道解决方案吗?

1 个答案:

答案 0 :(得分:1)

在插入之前使用addslashes

$img = addslashes(file_get_contents($_FILES['images']['tmp_name']));
$query = "INSERT INTO tableName (id,image) VALUES('','$image')"; 
相关问题