Jump to content

getting pdf from mssql error on some documents


fayne

Recommended Posts

Hello,

 

I have a page where users can insert pdf-document into my mssql database.

The selected pdf get converted with the following lines and then inserted into a image column in my mssql database.

$filename = $_FILES["pdf"]["tmp_name"]; 
$datastring = file_get_contents($filename; 
$arrdata = unpack("H*hex", $datastring); 
$content = "0x".$arrdata['hex'];

Now on another page the user can view the pdf they inserted into the database with the following code;

$query = odbc_exec($conn, "SELECT name, size, type, document FROM documents WHERE id='". $id ."'");
while (odbc_fetch_row($query)) {
	$filename = odbc_result($query,"name");
	$filesize = odbc_result($query,"size");
	$filetype = odbc_result($query,"type");
	$filedata = odbc_result($query,"document ");
	
	header("Content-Length: ". $filesize ."");
	header("Content-Type: ". $filetype ."");
	header("Content-Disposition: attachment; filename=". $filename ."");
	echo $filedata;
}

This is all working perfectly with pdf files below 500kb.

But once a pdf document exceeds the 500kb I get an error downloading the pdf file with the above script.

And the pdf-document gets inserted right because from my vb.net tool I still can open the pdf-document from the mssql database.

 

Is there some kind of limit in php that when a file exceeds 500kb he won't show/download it?

Can someone explain me how I can adjust this so that pdf documents that are bigger then 500kb still can be opened from the php page?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.