0

I have one sql server 2008 database table in which i am storing all types of documents i.e. doc,docx,pdf,image. the datatype of the data field is 'image'.

Data is stored in database. But i need to retrieve it and display it in my php page. I dont need to save or change it but user only need to view that document.

I am using simple select query like

select docid,docname,data from documents

The data field results in System.Byte[].

What do i need to do to print that document in my php application ?

Please help me.

  • Thanks in Advance.

Mausami

Mausami
  • 692
  • 1
  • 13
  • 24

1 Answers1

0

To display directly from memory you're going to need to know the mimetype. In tables that store random files like that the usual process is to also store the type of file and mimetype in another field. Do you have access to that kind of data?

If you do know the mimetype then you can notify the browser what to expect with the technique used the answers posted to this similar question. Google Header Content-Type for more information.

If you don't know the file mime type then your probably going to have to save the binary to a file locally on your webserver and then attempt to display it from there and hope the browser knows what to do with the file type.

Community
  • 1
  • 1
RThomas
  • 10,702
  • 2
  • 48
  • 61
  • Yes i can have the mimetype data from database as m storing type of document in to the database table. i tried to do this : $file=$doc["filedata"]; $length = strlen($file); header("Content-type: application/pdf"); header("Content-Length: $length"); header("Content-Disposition: inline; filename='$filename'"); echo $file; ----- but the result is 'System.Byte[]'. what should i need to do ? – Mausami Jan 24 '13 at 23:19