使用PHP将PDF另存为blob吗? [英] Save PDF as a blob in a database using PHP?

查看:183
本文介绍了使用PHP将PDF另存为blob吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器上有一个PDF文件,我想选择该文件并将其转换为blob以插入到数据库中(使用INSERT INTO命令).我的第一个问题是使用PHP掌握PDF.我知道它是通过file_get_contents()函数完成的,但是我不知道它需要什么参数.

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.

推荐答案

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

您可以将$ content保存到mysql中的blob字段

You can save the $content to blob field in mysql

这篇关于使用PHP将PDF另存为blob吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆