Re: Download code for downloading a file
I would imagine if you are getting an empty file you a referencing the file incorrectly. Try echo out your path and make sure its correct. make sure On Jul 24, 5:39 pm, Vijay Kumbhar wrote: > i have removed that array too. but it is not still giving the file to > download. > > > > On Fri, Jul 24, 2009 at 8:06 AM, brian wrote: > > > mimeType should be a string, not an array. Why do you assign it as > > array($result['Application']['type'])? > > > On Thu, Jul 23, 2009 at 2:23 PM, Vijay Kumbhar wrote: > > > Hello Brian, > > > > Thanks for your reply.I have done as you told it gave me the $param > > values. > > > But it is not giving me download window :( . > > > > here is code as you told to comment the part, > > > > //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); > > > > die(debug($params)); > > > > And the output is as follows, > > > > app/controllers/applications_controller.php (line 198) > > > > Array > > > ( > > > [name] => resume-1 > > > [download] => 1 > > > [extension] => doc > > > [path] => MY_SERVER_DOCUMENT_PATH/app/webroot/uploads/ > > > [mimeType] => Array > > > ( > > > > [0] => application/msword > > > ) > > > > ) > > > > Please help. > > > > On Thu, Jul 23, 2009 at 10:15 PM, brian wrote: > > > >> I like how you left my snarky comment in the code I'd posted :-) > > > >> Try commenting out the Configure::write('debug', 0) and, after you've > > >> set the $params array, put: > > > >> die(debug($params)); > > > >> ... so that you can see if the values are all what you're expecting. > > > >> Of course, you should also ensure that the file is where you think it > > >> is and that the permissions allow the server to read it. > > > >> On Thu, Jul 23, 2009 at 10:44 AM, Vijay 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Download code for downloading a file
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 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. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Real noob question
Coffee and lunch = $this->set('total', $this->Inventory->find ('count')); On Jun 18, 12:48 pm, Rufus wrote: > I have a simple count: > > function view($id = null) { > if (!$id) { > $this->Session->setFlash(__('Invalid Inventory.', > true)); > $this->redirect(array('action'=>'index')); > } > $this->set('inventory', $this->Inventory->read(null, $id)); > > $total = $this->Inventory->find('count'); > > } > > How do I now display $total in my view? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Real noob question
I have a simple count: function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid Inventory.', true)); $this->redirect(array('action'=>'index')); } $this->set('inventory', $this->Inventory->read(null, $id)); $total = $this->Inventory->find('count'); } How do I now display $total in my view? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: What do you develop in (ide, text editor, etc.)?
pspad On Mar 2, 7:35 am, Samuel DeVore wrote: > a tutu and go go boots > > On Sun, Mar 1, 2009 at 12:34 PM, Tomás Laureano Peralta Tormey > > wrote: > > Currently using NetBeans 6.5. The hints from this bakery article [1] were > > really useful. > > Hopefully, better support for CakePHP could be available in the near future > > (if this issue [2] get enough votes). > > > [1]: > >http://bakery.cakephp.org/articles/view/model-based-code-insight-and-... > > [2]:http://www.netbeans.org/issues/show_bug.cgi?id=140918 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting kicked out by auth when displaying blobs
This is true I hope, I am using prepared statements with mysqli so they should be getting cached as far as I can tell from the documentation. Is a database not a file anyway? On Apr 15, 12:33 pm, Sidney wrote: > Without discussing the pros/cons of whether to use blobs in the 1st > place, one point to note is that with caching, the binary data will > get served from the file system in most cases anyway. > > On Apr 15, 9:08 am, Rufus wrote: > > > The images are from 4-20k max and it seems pretty darn speedy. Also > > the web app is just a management portal for an advertising widget, so > > it will only be used by 3 or 4 people at any one time. > > > So I think nobody can argue that it is not ok to store it as a blob in > > this situation? > > > On Apr 15, 2:04 am, brian wrote: > > > > On Tue, Apr 14, 2009 at 3:45 AM, burzum wrote: > > > > > You should use the MediaView class (see API documentation) to send or > > > > display the file data. > > > > I hadn't thought of that. I suppose it would need to be overloaded, > > > though, to deal with data from the DB. > > > > > And files should not be stored in a database in > > > > the case of a web app. > > > > That's a matter of opinion (and use-case). I certainly wouldn't do > > > that for regular images but there are legitimate reasons for storing > > > some files in a DB. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting kicked out by auth when displaying blobs
The images are from 4-20k max and it seems pretty darn speedy. Also the web app is just a management portal for an advertising widget, so it will only be used by 3 or 4 people at any one time. So I think nobody can argue that it is not ok to store it as a blob in this situation? On Apr 15, 2:04 am, brian wrote: > On Tue, Apr 14, 2009 at 3:45 AM, burzum wrote: > > > You should use the MediaView class (see API documentation) to send or > > display the file data. > > I hadn't thought of that. I suppose it would need to be overloaded, > though, to deal with data from the DB. > > > And files should not be stored in a database in > > the case of a web app. > > That's a matter of opinion (and use-case). I certainly wouldn't do > that for regular images but there are legitimate reasons for storing > some files in a DB. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting kicked out by auth when displaying blobs
Thanks a mil, I set it to medium and I am no longer getting kicked. Dont know why session timeout has anything to do with it but meh. Thanks Brian On Apr 14, 3:16 am, brian wrote: > I suspect this is due to the same session problems some people have > been having. You're making a 2nd request for the img. That's not out > of the ordinary, in itself, but this request goes through Dispatcher > and so Auth gets involved. It may have something to do with > Security.level (in core.php) being set to 'high'. > > On Mon, Apr 13, 2009 at 3:49 AM, Rufus wrote: > > > Also I am displaying the image like so: > > > > > > src="http://site.com/ > > images/display/'.$image['Image']['id'].'" title="'.$image['Image'] > > ['name'].'" alt="'.$image['Image']['name'].'" />'; ?> > > > > > This is where the problem lies I think --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting kicked out by auth when displaying blobs
Also I am displaying the image like so: http://site.com/ images/display/'.$image['Image']['id'].'" title="'.$image['Image'] ['name'].'" alt="'.$image['Image']['name'].'" />'; ?> This is where the problem lies I think --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Getting kicked out by auth when displaying blobs
Ahoi, I have been getting kicked out of cake whenever I display a blob image in cake. Here is my function: function display($id) { if (!$id) { $this->Session->setFlash(__('Invalid Image.', true)); $this->redirect(array('action'=>'index')); } Configure::write('debug', 0); $file = $this->Image->findById($id); header("Content-type: ".$file['Image']['type']); echo $file['Image']['image']; } I have also put a before filter in my images controller: function beforeFilter() { parent::beforeFilter(); $this->Auth->allowedActions = array('display'); } Its not a major problem for this app but it is anoying, any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Display a blob in a view
Yes Daffy you have the ticket. It seems you cant set a variable off the array like i tried to do: this is bad: $type = $file['ImageUpload']['type']; header('Content-type: ' . $type); this is good: $type = $file['ImageUpload']['type']; here is a follow-up post: http://groups.google.com/group/cake-php/browse_thread/thread/d9fe1b765325667e?hl=en# On Mar 18, 5:36 am, Daffy wrote: > Our ways are similar. What is the base64_decode for? > > This is how I do it. > > Controller: > > function display($id) { > Configure::write('debug', 0); > $file = $this->ImageUpload->findById($id); > echo $file['ImageUpload']['thumb']; > header('Content-type: ' . $file['ImageUpload']['type']); > exit(); > > } > > View: > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Blob image display problem solved
Hi, I was trying to get an image to display using the following: function display($id) { Configure::write('debug', 0); $file = $this->Image->findById($id); $data = $file['Image']['image']; $type = $file['Image']['type'] header("Content-type: ".$type); echo $data; } obviously (but not to me) you cant set the variable off the array value or something? - i r noob This fixed it: function display($id) { Configure::write('debug', 0); $file = $this->Image->findById($id); header("Content-type: ".$file['Image']['type']); echo $file['Image']['image']; } Anyway echo out the array value and it worked perfectly. Hope this helps somebody else. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Display a blob in a view
Hi, I have going through all the discussions looking for an easy way to show a blob in a view. I have got to what I think is the most simple way of doing it. Controller: function display($id) { Configure::write('debug', 0); $file = $this->Image->findById($id); $type = $file['Image']['type']; $data = base64_decode($file['Image']['image']); header("Content-type: $type"); echo "$data"; exit(); } View: echo ''; All I get in FF is the alt tag and in IE I get the gobligook. Any thoughts? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Capture webcam stream from client and upload it as a flash video to server
Hi. Is it possible to get this in CakePHP? I think to use Red5 (osflash.org/red5) as a flash server, CakePHP, AMFPHP. I'd like to build something like Youtube Quick Upload. Has anyone got anything similar using these tools? Regards rufus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---