Hello Peter,
I can't use files from filesystem. Let's say that they are not on the
some mashine where is application that has to show files :-) So it has
to be in exact order as I wrote :-(
Advertising
2010/7/27 Peter Lind <peter.e.l...@gmail.com>:
> 2010/7/27 Dušan Novaković <ndu...@gmail.com>:
>> Hello,
>>
>> so when I'm sending the array to model it's like this:
>>
>> $fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
>> $pdfContent = array(
>> 'file' =>
>> base64_encode(fread($fp,
>> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
>> 'name' => $pdfName,
>> 'size' =>
>> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
>> 'type' =>
>> mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
>> );
>> fclose($fp);
>>
>> so the data in db are ok, and this type is application/pdf.
>>
>> And when I'm getting data, I get the array like this:
>>
>> $file = Array
>> (
>> [id] => 2
>> [file] =>VBERi0xLjM... <= here file is base64_encode()
>> [file_size] => 2204
>> [file_type] => application/pdf
>> [file_name] => 2_file.pdf
>> )
>>
>> Headers:
>>
>> header("Content-length: ".$file['file_size']);
>> header("Content-type: ".$file['file_type']);
>> header("Content-Disposition: attachment; filename= ".$file['file_name']);
>> echo base64_decode($file['file']);
>>
>>
>> So, mime looks ok, but still... not working :-(
>>
>> 2010/7/27 Nilesh Govindarajan <li...@itech7.com>:
>>> Have you checked the headers? Its mostly a mime time issue I feel.
>>> What do you see in Content-Type? It should be application/pdf (or
>>> application/x-pdf, unsure) for PDF files.
>>>
>>> --
>>> Regards,
>>> Nilesh Govindarajan
>>> Facebook: http://www.facebook.com/nilesh.gr
>>> Twitter: http://twitter.com/nileshgr
>>> Website: http://www.itech7.com
>>> VPS Hosting: http://www.itech7.com/a/vps
>>>
>>
>>
>>
>> --
>> mob: + 46 70 044 9432
>> web: http://novakovicdusan.com
>>
>> Please consider the environment before printing this email.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Why are you storing files in the db in the first place? If they're
> files why not use the filesystem?
>
> Regards
> Peter
>
> --
> <hype>
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> </hype>
>
--
mob: + 46 70 044 9432
web: http://novakovicdusan.com
Please consider the environment before printing this email.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php