hello Asyraf Wahi Anuar... have you already got the solution to this problem. i also encounter the same problem with you. i hope you can share with me your solution. tq
On Monday, April 8, 2013 11:41:10 PM UTC+8, Asyraf Wahi Anuar wrote:
-- On Monday, April 8, 2013 11:41:10 PM UTC+8, Asyraf Wahi Anuar wrote:
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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment