Yes. im trying to force down the file into user computer.

On Wednesday, April 10, 2013 8:41:20 PM UTC+8, André Luis wrote:
>
> Are you trying to force the file download?
>
> Em segunda-feira, 8 de abril de 2013 12h41min10s UTC-3, Muhammad Asyraf 
> escreveu:
>>
>> Based from tutorial at 
>> http://www.tuxradar.com/content/cakephp-tutorial-build-file-sharing-application
>>  , 
>> i manage to upload file and it capture the filename, filesize and filemime 
>> without any error but when download the file, it will produce wrong file 
>> mime for example, the file mime should be .jpg but in Google chrome it will 
>> be .htm and in IE it only download file with the name but no extension for 
>> that file. it seem something wrong with the controller codes.
>>
>> function download($id = null) {
>> if (!$id) {
>> $this->Session->setFlash(__('Invalid id for upload', true));
>> $this->redirect(array('action' => 'index'));
>> }
>> $this->Upload->bindModel(array('hasOne' => array('UploadsUser')));
>> $upload = $this->Upload->find('first', array(
>> 'conditions' => array(
>> 'Upload.id' => $id,
>> 'OR' => array(
>> 'UploadsUser.user_id' => $this->Auth->user('id'),
>> 'Upload.user_id' => $this->Auth->user('id'),
>> ),
>> )
>> ));
>> if (!$upload) {
>> $this->Session->setFlash(__('Invalid id for upload', true));
>> $this->redirect(array('action' => 'index'));
>> }
>> $this->viewClass = 'Media'; 
>> $filename = $upload['Upload']['filename'];
>> $this->set(array(
>> 'id' => $upload['Upload']['id'],
>> 'name' => substr($filename, 0, strrpos($filename,'.')), 
>> *'extension' => substr(strrchr($filename,'.'), 1),*
>> 'path' => APP.'uploads'.DS,
>> 'download' => true,
>> ));
>> }
>>
>>
>> Based on the codes, maybe the extension have problem. Anyone can help? 
>> thanks...
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to