php - Insert pdf as blob and display -


so i'm getting pdf file send webservice me upload, it's send me base64binary type variable,

and uploaded using below script :

function saveeim($parameters) {    mysql_query("insert tablename (filename, filesize, file)                  values ( '" . $parameters['filename'] . "', '". $parameters['filesize'] . "', '" . $parameters['file'] . "' ) ") or die (mysql_error()); } 

now getting uploaded, weird thing is, instance if upload 370kb file, it's 490kb in database.... don't know how happens, , if normal?

now save in fileserver :

$query = mysql_query("select file tablename id = '1' ") or die (mysql_error()); $fetch = mysql_fetch_array($query); $data = $fetch[0]; file_put_contents("user_123.pdf", $data); 

when open file getting saved in fileserver, error : "user_123.pdf cannot opened because filetype not supported or because damaged."

i'm new blob types, , know storing files on server better, have use blob times, since asked so.

if me out here, appreciated.

solved it, had use base64_decode($data) on blobtype.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -