Save PDF as a blob in a database using PHP?

白昼怎懂夜的黑 提交于 2019-12-12 06:45:27

问题


I have a PDF file on my server that I want to select and transform into a blob for insertion into my database (using an INSERT INTO command). My first problem is getting hold of the PDF using PHP. I know it is done with the file_get_contents() function, but I do not understand what parameters it needs.


回答1:


$fp = fopen($fileLocation, 'r');
$content = fread($fp, filesize($fileLocation));
$content = addslashes($content);
fclose($fp);

You can save the $content to blob field in mysql



来源:https://stackoverflow.com/questions/43071537/save-pdf-as-a-blob-in-a-database-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!