Re: storing files in database and retriving them

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :-(

2010/7/27 Peter Lind <peter.e.lind@xxxxxxxxx>:
> 2010/7/27 Dušan Novaković <ndusan@xxxxxxxxx>:
>> 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 <lists@xxxxxxxxxx>:
>>> 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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux