Get blob string size before loading in Mysql

I read the answers to the questions on this question, but none of them concerns my exact problem. I create pdf after submitting the form and uploading this pdf to MySQL. Is there a way with PHP to create a PDF file and check its file size before I upload it? My script below works fine. Turns a pdf file into a string and puts it in the database, I'm just not sure how to check the size of the string, so I can add it as a variable. I am new to PHP, so I'm not sure if this is possible. Thanks.

$pdffilecontent = $pdf->Output('', 'S'); $name = "Feedback One"; $mime = "application/pdf"; //$md5 = md5_file($pdffilecontent); $data = mysql_real_escape_string($pdffilecontent); $link = "INSERT INTO `images` (`filename`, `mime_type`, `file_data`)VALUES ('{$name}', '{$mime}', '{$data}')"; $results = mysql_query($link) or die("Error in query: fda. " . mysql_error()); $id = mysql_query("SELECT image_id FROM images ORDER BY image_id DESC LIMIT 0,1"); $temp = mysql_fetch_row($id); $id = $temp[0]; $answer = "INSERT INTO imagsub (imagesub_id, submission_id, user_id, image_id) VALUES ('NULL', '$hidden', '" . $outcome['id'] . "' ,'" . $id . "')"; mysql_query($answer) or die("Error in query: fda2. " . mysql_error()); 
+4
source share
1 answer

You probably solved this a year ago ... but, when prompted by Ren, I add this as an answer (to clear the remaining queue):

Q: Have you tried "strlen ($ pdffilecontent)"?

+2
source

Source: https://habr.com/ru/post/1391520/


All Articles