Also i have created a code & it also worked.................... :)
// your file to upload
$result = $this->Application->findById($id);
// your file to upload
$file = APP."webroot/uploads".DS.$result['Application']['resume'];
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: ".$result['Application']['type']."" );
header("Content-Disposition: attachment;
filename=\"".$result['Application']['resume']."\";");
header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".$filesize);
readfile($file);
exit;
On Fri, Jul 24, 2009 at 1:28 PM, Vijay Kumbhar <[email protected]> wrote:
> Yeah...
>
> Thanks rufus it works .........
>
> only i changed this line,
>
> header('Content-Type: application/octet-stream'); to
>
> header("Content-Type: ".$result['Application']['resume'])."");
>
> that is the content type of the uploaded file coming from my database.
>
>
> Thanks again...............
>
>
> On Fri, Jul 24, 2009 at 12:53 PM, Rufus <[email protected]> wrote:
>
>>
>> Here is my code:
>>
>> pdfDir is defined constant fyi
>>
>>
>> function download($id = null) {
>>
>> if (!$id && empty($this->data)) {
>> $this->Session->setFlash(__('Invalid Invoice',
>> true));
>> $this->redirect(array('action'=>'index'));
>> }
>>
>> Configure::write('debug', 0);
>> $file = $this->Invoice->findById($id);
>> if (file_exists(pdfDir.$file['Invoice']['file_name'])) {
>> header('Content-Description: File Transfer');
>> header('Content-Type: application/octet-stream');
>> header('Content-Disposition: attachment; filename='.basename
>> (pdfDir.$file['Invoice']['file_name']));
>> header('Content-Transfer-Encoding: binary');
>> header('Expires: 0');
>> header('Cache-Control: must-revalidate, post-check=0, pre-
>> check=0');
>> header('Pragma: public');
>> header('Content-Length: ' . filesize(pdfDir.$file['Invoice']
>> ['file_name']));
>> ob_clean();
>> flush();
>> readfile(pdfDir.$file['Invoice']['file_name']);
>> exit;
>> } else {
>> $this->Session->setFlash(__('File Does Not Exist',
>> true));
>> $this->redirect(array('action'=>'index'));
>> }
>>
>> }
>>
>> On Jul 24, 12:44 am, Vijay <[email protected]> wrote:
>> > Hello All,
>> >
>> > I uploads the files to webroot/uploads folder from the file uploading
>> > component.
>> >
>> > Now I am trying to download that file from webroot/uploads folder but
>> > it is giving me 0 byte file.
>> >
>> > Code is as follows,
>> >
>> > function admin_download($id)
>> > {
>> > $this->adminchecksession();
>> > // you'll want to check the login status here ...
>> >
>> > $result = $this->Application->findById($id);
>> >
>> > Configure::write('debug', 0);
>> > $this->view = 'Media';
>> >
>> > /* MediaView is really irritating
>> > */
>> > //$name = $result['Application']['resume'];
>> >
>> > $ext = explode("." ,$result['Application']['resume']);
>> >
>> > $params = array(
>> > 'name' => $ext[0],
>> > 'download' => true,
>> > 'extension' => $ext[1],
>> > 'path' => APP."webroot/uploads".DS,
>> > 'mimeType' => array($result['Application']
>> > ['type'])
>> > );
>> >
>> > $this->set($params);
>> >
>> > }
>> >
>> > Please help me on this.
>> >>
>>
>
>
> --
> Thanks & Regards,
> Vijayk.
> Co-founder (www.weboniselab.com)
>
> "You Bring the Dreams, We'll Bring the Means"
>
--
Thanks & Regards,
Vijayk.
Co-founder (www.weboniselab.com)
"You Bring the Dreams, We'll Bring the Means"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---