-1

How can i store and retrieve a PDF file into a Mysql database? Havent found any thing reasonable on here.

  • Possible duplicate of [How to store .pdf files into MySQL as BLOBs using PHP?](https://stackoverflow.com/questions/4813913/how-to-store-pdf-files-into-mysql-as-blobs-using-php) – creimers Jul 14 '17 at 08:05

1 Answers1

0
$value = file_get_contents('yourpdf.pdf')

Then record $value in your database.

MorganFreeFarm
  • 3,811
  • 8
  • 23
  • 46
  • then how about displaying it? and Do i get to save it as BLOB? – James Ibrahimov Jul 14 '17 at 07:46
  • U can't save file directly to database, u can use http://php.net/manual/en/function.move-uploaded-file.php this to move it and then this to open it http://php.net/manual/en/function.fopen.php . In database u need to save path to this file. – MorganFreeFarm Jul 14 '17 at 07:51
  • i have used move_uploaded_file to move to a folder i call resume. When you say save path to file, you you mean the tmp? – James Ibrahimov Jul 14 '17 at 07:56
  • $temp = $_FILES["avatar"]["tmp_name"]; $name = $_FILES["avatar"]["name"]; $size = $_FILES["avatar"]["size"]; move_uploaded_file($temp, __SITE_PATH . "/pictures/" . $name); $path = URL . '/pictures/' . $name; This is basic example. U need to save in DB $path – MorganFreeFarm Jul 14 '17 at 08:01
  • i managed to use ma calculations and indeed i was able to catch what you meant. did this and it saved to a location, then i used $row['cv_path'] to hyperlink it and then it was able to view. Thanks again. – James Ibrahimov Jul 14 '17 at 08:28