gs-gruppen Posted February 28, 2010 Share Posted February 28, 2010 Hi all I have "tried" everything :-) Surely not - but I can't make this PHP-code working - it seem that the insert into the database works, as I can see a record - and the blobfield is "[bLOB - 5,7 KiB]" The size is correct. BUT download and displaying the PDF file - dosn't work. Either it states the file is un-readable or it's blank - or damage. The PDF reader has giving me different messages, during my many tests!!! The PDF-file is already on the server!!! I surely most do something wrong - but what it is - I can't figure out :-( I will be grateful for some assistance :-) I have created a table with some fields like these: * key * Text * Longblob * Name => See all of them in the code....... <?php $overskrift = "OOOO'; $firma = "FFFFF"; $forfatter = "RRRRRr"; $kategori = "EVENT"; $metadata = "Meta data text"; //$fname = "D2008.2.5.doc"; $fname = "Referat.pdf"; $size = filesize("$fname"); $type = 'application/pdf'; $fp =fopen($fname, 'rb'); $content = fread($fp, $size); $content = addslashes($content); fclose($fp); require("xxxxxxxxxxxxxxx.php"); mysql_query("Insert into arkiv (overskrift, firma, forfatter, kategori, navn, metadata, indhold, type, size) values ('$overskrift', '$firma', '$forfatter', '$kategori', '$fname', '$metadata', '$content', '$type', $size)"); echo mysql_error(); header('Content-length:'.$size); header('Content-type:'.$type); header('Content-Disposition:attachment;filename='.$fname); echo $content; exit(); ?> Link to comment https://forums.phpfreaks.com/topic/193698-upload-and-download-files-to-mysql/ Share on other sites More sharing options...
Dennis1986 Posted February 28, 2010 Share Posted February 28, 2010 Read this and compare your script/method with this: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx Link to comment https://forums.phpfreaks.com/topic/193698-upload-and-download-files-to-mysql/#findComment-1019570 Share on other sites More sharing options...
gs-gruppen Posted February 28, 2010 Author Share Posted February 28, 2010 Hi! That instruction page - is just the one I have been using as guide, event when I have changed some of the code! I believe it's a good and very clear guide, and anyhow I can't make it work Anyway - I will run through it again - and let you know - but feel free to come forward with other corrections Link to comment https://forums.phpfreaks.com/topic/193698-upload-and-download-files-to-mysql/#findComment-1019600 Share on other sites More sharing options...
gs-gruppen Posted March 1, 2010 Author Share Posted March 1, 2010 :( :( Tried go through it all again - still same error - when the download. Anyone - know if server-side-setup can break this kind of function or other PHP-coding can ensure it somehow? Link to comment https://forums.phpfreaks.com/topic/193698-upload-and-download-files-to-mysql/#findComment-1020061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.