I have a file in the location
我在该位置有一个文件
$imgloc = "../images/bg.jpg";
How do I:
我如何能:
- Load the image into a PHP variable
- Turn into a BLOB suitable data type (if not already)
- Insert into MySQL (If any additional steps are needed)
将图像加载到PHP变量中
变成BLOB合适的数据类型(如果还没有)
插入MySQL(如果需要任何其他步骤)
1 个解决方案
#1
$imgHandler = fopen (imgloc, 'rb'); // open with read binary
$imgContent = fread ($imgHandler , filesize ($imgloc));
// now you can store $imgContent in MySQL
#1
$imgHandler = fopen (imgloc, 'rb'); // open with read binary
$imgContent = fread ($imgHandler , filesize ($imgloc));
// now you can store $imgContent in MySQL