[php]把 binary 檔放到 SQL

php 要如何把 binary 檔放到 SQL 中呢?
網路上找到的大多是
$binaryfile= fread(fopen($file, ‘r’), filesize($file));

不過我自己試的結果是問題一大堆 -_-

還好 phpMyAdmin 對這個有特別的處理方式

廢話不多說, 先來段 code 吧 !

$binary= fread(fopen($file, ‘rb‘), filesize($file));
$binary= ‘0x’. bin2hex($binary);

就是多了那個 b … 可以到這邊看看
不過他只指出用法, 並沒有多說明, 所以我也不知道在那邊 ~”~

any way 又解決一個快問題的感覺真好 :D

One Response to “[php]把 binary 檔放到 SQL”

  1. stop popups says:

    I stumbled on this from Google and wanted to say thanks for posting

Leave a Reply