dear ivnrmc, all I'm having a problem is with saving to a database... the upload is working,... all I need is to save in db,... I follow the book instruction and could not save it too...
this code is working in 1.2 version if($this->Photo->save(array('Photo' => array('name' => $name, 'user_id' => $this->user['id'], 'secret' => $secret, 'hidden' => 0, 'privacy' => array_search($_GET['privacy'], Configure::read('Site.privacy')))))) { .... all I need is to make it save in 1.3 version thanks On Friday, October 5, 2012 4:52:50 PM UTC-7, ivnrmc wrote: > > download the meio upload and use it as a behavior for your model. this > will solve all of your problems, setting it up is minimal. > > > > > 2012/10/6 Chris <chri...@yahoo.com <javascript:>> > >> I'm uploading photos in webroot/photos ... and its working,... the only >> thing is it need to add to a database after upload, which is not doing,... >> here is whole function: >> >> function upload() >> { >> $this->authorize(); >> >> $user = $this->User->findById($this->user['id']); >> >> if(!($user && ($user['User']['photos_limit'] == 0 || >> $user['User']['photos'] < $user['User']['photos_limit']))) >> { >> header('HTTP/1.1 401 Unauthorized'); >> exit('You reached your upload limit'); >> } >> else >> { >> $fileParts = pathinfo($_FILES['Filedata']['name']); >> $secret = $this->generateRandomString(20); >> $name = str_replace(array('.jpg', '.jpeg', '.JPG', '.JPEG', '.png', >> '.PNG'), '', $fileParts); >> >> $tempFile = $_FILES['Filedata']['tmp_name']; >> $original_file = $this->Photo->getOriginalFile($this->Photo->id, >> $secret, true); >> $original_file_path = $original_file->pwd(); >> $targetFile = $original_file_path; >> >> move_uploaded_file($tempFile, $targetFile); >> >> exec('/usr/bin/convert -geometry 768x640 ' . $targetFile . ' ' . >> $this->Photo->getLargeFile($this->Photo->id, $secret)->pwd() .' > /dev/null >> 2>&1 &'); >> exec('/usr/bin/convert -geometry 400x360 ' . $targetFile . ' ' . >> $this->Photo->getMediumFile($this->Photo->id, $secret)->pwd() .' > >> /dev/null 2>&1 &'); >> exec('/usr/bin/convert -geometry 135x135 ' . $targetFile . ' ' . >> $this->Photo->getSmallFile($this->Photo->id, $secret)->pwd() .' > /dev/null >> 2>&1 &'); >> exec('/usr/bin/convert -geometry 140x220 ' . $targetFile . ' ' . >> $this->Photo->getThumbFile($this->Photo->id, $secret)->pwd() .' > /dev/null >> 2>&1 &'); >> exec('/usr/bin/convert -thumbnail x480 -resize "480x<" -resize >> 50% -gravity center -crop 240x240+0+0 +repage ' . $targetFile . ' ' . >> $this->Photo->getBannerFile($this->Photo->id, $secret)->pwd() .' > >> /dev/null 2>&1 &'); >> exec('/usr/bin/convert -thumbnail x150 -resize "150x<" -resize >> 50% -gravity center -crop 75x75+0+0 +repage ' . $targetFile . ' ' . >> $this->Photo->getSquareFile($this->Photo->id, $secret)->pwd() .' > >> /dev/null 2>&1 &'); >> exec('/usr/bin/convert -thumbnail x96 -resize "96x<" -resize 50% >> -gravity center -crop 48x48+0+0 +repage ' . $targetFile . ' ' . >> $this->Photo->getBuddyFile($this->Photo->id, $secret)->pwd() .' > /dev/null >> 2>&1 &'); >> >> $this->Photo->create(); >> if($this->Photo->save(array('Photo' => array('name' => $name, >> 'user_id' => $this->user['id'], 'secret' => $secret, 'hidden' => 0, >> 'privacy' => array_search($_GET['privacy'], >> Configure::read('Site.privacy')))))) >> { >> $this->User->query('UPDATE fociki_users' . >> ' SET photos = photos + 1' . >> ', last_public_photo = (SELECT created FROM fociki_photos WHERE >> user_id = ' . $this->user['id'] . ' AND fociki_photos.privacy <= ' . >> array_search('public', Configure::read('Site.privacy')) .' ORDER BY created >> DESC LIMIT 1)' . >> ', last_friend_photo = (SELECT created FROM fociki_photos WHERE >> user_id = ' . $this->user['id'] . ' AND fociki_photos.privacy <= ' . >> array_search('friend', Configure::read('Site.privacy')) .' ORDER BY created >> DESC LIMIT 1)' . >> ' WHERE id = ' . $this->user['id']); >> } >> >> $this->Session->setFlash(__('The photos are saved.', true)); >> >> } >> } >> >> >> On Friday, October 5, 2012 2:51:39 PM UTC-7, ivnrmc wrote: >> >>> what are your error? this code is on very big mess. I don't know what >>> are you trying to do, but you should clean and simplify all of this. >>> >>> 2012/10/5 Chris <chri...@yahoo.com> >>> >>>> hi guys,... >>>> I can't save data in database,... I'm on cake 1.3 what am I doing >>>> wrong...? can anyone help please,....? >>>> thanks in advance >>>> >>>> >>>> $this->Photo->create(); >>>> if($this->Photo->save(array('**Photo' => array('name' => $name, >>>> 'user_id' => $this->user['id'], 'secret' => $secret, 'hidden' => 0, >>>> 'privacy' => array_search($_GET['privacy'], Configure::read('Site.privacy' >>>> **)))))) >>>> { >>>> $this->User->query('UPDATE fociki_users' . >>>> ' SET photos = photos + 1' . >>>> ', last_public_photo = (SELECT created FROM fociki_photos WHERE >>>> user_id = ' . $this->user['id'] . ' AND fociki_photos.privacy <= ' . >>>> array_search('public', Configure::read('Site.privacy'**)) .' ORDER BY >>>> created DESC LIMIT 1)' . >>>> ', last_friend_photo = (SELECT created FROM fociki_photos WHERE >>>> user_id = ' . $this->user['id'] . ' AND fociki_photos.privacy <= ' . >>>> array_search('friend', Configure::read('Site.privacy'**)) .' ORDER BY >>>> created DESC LIMIT 1)' . >>>> ' WHERE id = ' . $this->user['id']); >>>> } >>>> >>>> -- >>>> Like Us on FacekBook >>>> https://www.facebook.com/**CakePHP<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 post to this group, send email to cake...@googlegroups.com. >>>> To unsubscribe from this group, send email to cake-php+u...@** >>>> googlegroups.com. >>>> >>>> Visit this group at >>>> http://groups.google.com/**group/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en> >>>> . >>>> >>>> >>>> >>> >>> >>> >>> -- >>> *Ivan Rimac*** >>> mail: ivn...@gmail.com >>> *tel: +385 95 555 99 66* >>> *http://ivanrimac.com* >>> >>> -- >> Like Us on FacekBook 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 post to this group, send email to cake...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> cake-php+u...@googlegroups.com <javascript:>. >> Visit this group at http://groups.google.com/group/cake-php?hl=en. >> >> >> > > > > -- > *Ivan Rimac*** > mail: ivn...@gmail.com <javascript:> > *tel: +385 95 555 99 66* > *http://ivanrimac.com* > > -- Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.