Re: File uploads, image uploads
clemos wrote: > hi jon and all > > what is on line 219 of your > /myserver/app/controllers/businesses_controller.php ? > > for file upload, I actually use this component which does perfectly the job : > http://cakeforge.org/snippet/detail.php?type=snippet&id=36 > I've written my own File model, FilesController and stuff around it, > all of which are quite simple (the files table has only > "id","name","location","mime","extension")... > > and I populate the db by manipulating the $this->params['data'] array > after doing the FileHandler stuff, and before saving the model > for you it would be probably somethin like : > $this->params['data']['Business']['imageFile'] = > $_FILES[filename][name]; // or in my case : > $this->fileHandler->filename > $this->Business->save($this->params['data']); > (I don't know if it's the "good" way, but it works quite well to me) > (my File::add() function is in the bottom of this msg) > > anyway it seems to me more a CakePHP MVC issue than a problem of file > upload itself (you could get this error trying to populate your db > with any "off the conventions" stuff) > could you please tell us more about your businesses table, your > Business model and you businessesController ? > > > clemos > > = = = = = > > function add(){ > if(empty($this->params['data'])){ > > > > }else{ > > if($this->FileHandler->upload("upload","app/webroot/files/",null,true)){ > > > > $this->params['data']['Fichier']['location'] = > $this->webroot . > substr($this->FileHandler->location,12); //don't remember why it's > substr 12... > $this->params['data']['Fichier']['filename'] = > $this->FileHandler->filename; > $this->params['data']['Fichier']['mime'] = > $this->FileHandler->type; // added this property to FileHandler > component myself > $this->params['data']['Fichier']['extension'] = > strtolower($this->FileHandler->ext); // and this one too > > > > $this->Fichier->set($this->params['data']); > $this->Fichier->save(); > $this->flash('fichier > enregistré','/fichiers/'); > > > }else{ > $this->flash('erreur > #'.$this->FileHandler->error.' de > téléchargement du fichier ','/fichiers/'); > } > > } > > > } > > = = = = > > On 6/25/06, linkingarts <[EMAIL PROTECTED]> wrote: > > > > jb- > > > > thanks for the input but that isn't exactly the issue. What I don't > > quite get is a) why I'm getting an "index" error, and b) how to > > populate the db (with the imageFile [name] value in addition to the > > other values passed by the form) at the same time I'm uploading the > > file into a specific directory. > > > > BTW enctype is not the issue, it is in the form tag correctly (I > > mentioned that in the original post). > > > > Just still trying to get the hang of Cake overall; I'm getting most > > things to work here and there but it seems like every new thing I want > > to do takes 6 hrs to figure out. Then it's like, "ooh, sh---..." > > > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: File uploads, image uploads
hi friends, if v upload a file ,then the file(which was uploading by me) goes to where?? whether it wil go to database/webserver??? plz reply immediately.. i am new to php... clemos wrote: > hi jon and all > > what is on line 219 of your > /myserver/app/controllers/businesses_controller.php ? > > for file upload, I actually use this component which does perfectly the job : > http://cakeforge.org/snippet/detail.php?type=snippet&id=36 > I've written my own File model, FilesController and stuff around it, > all of which are quite simple (the files table has only > "id","name","location","mime","extension")... > > and I populate the db by manipulating the $this->params['data'] array > after doing the FileHandler stuff, and before saving the model > for you it would be probably somethin like : > $this->params['data']['Business']['imageFile'] = > $_FILES[filename][name]; // or in my case : > $this->fileHandler->filename > $this->Business->save($this->params['data']); > (I don't know if it's the "good" way, but it works quite well to me) > (my File::add() function is in the bottom of this msg) > > anyway it seems to me more a CakePHP MVC issue than a problem of file > upload itself (you could get this error trying to populate your db > with any "off the conventions" stuff) > could you please tell us more about your businesses table, your > Business model and you businessesController ? > > > clemos > > = = = = = > > function add(){ > if(empty($this->params['data'])){ > > > > }else{ > > if($this->FileHandler->upload("upload","app/webroot/files/",null,true)){ > > > > $this->params['data']['Fichier']['location'] = > $this->webroot . > substr($this->FileHandler->location,12); //don't remember why it's > substr 12... > $this->params['data']['Fichier']['filename'] = > $this->FileHandler->filename; > $this->params['data']['Fichier']['mime'] = > $this->FileHandler->type; // added this property to FileHandler > component myself > $this->params['data']['Fichier']['extension'] = > strtolower($this->FileHandler->ext); // and this one too > > > > $this->Fichier->set($this->params['data']); > $this->Fichier->save(); > $this->flash('fichier > enregistré','/fichiers/'); > > > }else{ > $this->flash('erreur > #'.$this->FileHandler->error.' de > téléchargement du fichier ','/fichiers/'); > } > > } > > > } > > = = = = > > On 6/25/06, linkingarts <[EMAIL PROTECTED]> wrote: > > > > jb- > > > > thanks for the input but that isn't exactly the issue. What I don't > > quite get is a) why I'm getting an "index" error, and b) how to > > populate the db (with the imageFile [name] value in addition to the > > other values passed by the form) at the same time I'm uploading the > > file into a specific directory. > > > > BTW enctype is not the issue, it is in the form tag correctly (I > > mentioned that in the original post). > > > > Just still trying to get the hang of Cake overall; I'm getting most > > things to work here and there but it seems like every new thing I want > > to do takes 6 hrs to figure out. Then it's like, "ooh, sh---..." > > > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: File uploads, image uploads
hi jon and all what is on line 219 of your /myserver/app/controllers/businesses_controller.php ? for file upload, I actually use this component which does perfectly the job : http://cakeforge.org/snippet/detail.php?type=snippet&id=36 I've written my own File model, FilesController and stuff around it, all of which are quite simple (the files table has only "id","name","location","mime","extension")... and I populate the db by manipulating the $this->params['data'] array after doing the FileHandler stuff, and before saving the model for you it would be probably somethin like : $this->params['data']['Business']['imageFile'] = $_FILES[filename][name]; // or in my case : $this->fileHandler->filename $this->Business->save($this->params['data']); (I don't know if it's the "good" way, but it works quite well to me) (my File::add() function is in the bottom of this msg) anyway it seems to me more a CakePHP MVC issue than a problem of file upload itself (you could get this error trying to populate your db with any "off the conventions" stuff) could you please tell us more about your businesses table, your Business model and you businessesController ? clemos = = = = = function add(){ if(empty($this->params['data'])){ }else{ if($this->FileHandler->upload("upload","app/webroot/files/",null,true)){ $this->params['data']['Fichier']['location'] = $this->webroot . substr($this->FileHandler->location,12); //don't remember why it's substr 12... $this->params['data']['Fichier']['filename'] = $this->FileHandler->filename; $this->params['data']['Fichier']['mime'] = $this->FileHandler->type; // added this property to FileHandler component myself $this->params['data']['Fichier']['extension'] = strtolower($this->FileHandler->ext); // and this one too $this->Fichier->set($this->params['data']); $this->Fichier->save(); $this->flash('fichier enregistré','/fichiers/'); }else{ $this->flash('erreur #'.$this->FileHandler->error.' de téléchargement du fichier ','/fichiers/'); } } } = = = = On 6/25/06, linkingarts <[EMAIL PROTECTED]> wrote: > > jb- > > thanks for the input but that isn't exactly the issue. What I don't > quite get is a) why I'm getting an "index" error, and b) how to > populate the db (with the imageFile [name] value in addition to the > other values passed by the form) at the same time I'm uploading the > file into a specific directory. > > BTW enctype is not the issue, it is in the form tag correctly (I > mentioned that in the original post). > > Just still trying to get the hang of Cake overall; I'm getting most > things to work here and there but it seems like every new thing I want > to do takes 6 hrs to figure out. Then it's like, "ooh, sh---..." > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: File uploads, image uploads
jb- thanks for the input but that isn't exactly the issue. What I don't quite get is a) why I'm getting an "index" error, and b) how to populate the db (with the imageFile [name] value in addition to the other values passed by the form) at the same time I'm uploading the file into a specific directory. BTW enctype is not the issue, it is in the form tag correctly (I mentioned that in the original post). Just still trying to get the hang of Cake overall; I'm getting most things to work here and there but it seems like every new thing I want to do takes 6 hrs to figure out. Then it's like, "ooh, sh---..." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: File uploads, image uploads
On 6/25/06, linkingarts <[EMAIL PROTECTED]> wrote: > > I want to populate a row in a database, and upload an image (into a > directory, not the db) from the same form. I'd also like to grab the > $_FILES[filename][name] param to go into the database. > > I have NO idea how to do this in Cake - no problem for me otherwise, > but I don't even know where to begin when it comes to doing this > w/Cake. (MVC Kung Fu is weak) > > Right now I've got a controller that functions fine to CRUD the data. I > tried out the Files Component by Nicolas Cohen (put it in > app/controllers/components as files.php > > http://cakeforge.org/snippet/detail.php?type=snippet&id=7 > > added this to the view: > > file('imageFile') ?> > > and this to the controller: > > add() > { > yada yada... > > if ($this->Business->save($this->params['data'])) > { > if ($_FILES['imageFile']) > { > $this->Files->saveAs('imageFile', $imgId, > WWW_ROOT . > 'img'.DS.'uploads'.DS); > } > > //cleanUpFields(effective_to_dt); > $this->flash('Your listing has been > saved.','/businesses'); > } > else { yada yada } > } > > I get this error: > > Notice: Undefined index: imageFile in > /myserver/app/controllers/businesses_controller.php on line 219 > > Is it trying to add imageFile to the db? > > FWIW, the upload dir is 777, and the form has the correct enctype. > > I've spent WAY too many hours on this one, searching the manual, wiki, > group, lurking on IRC... it's driving me nuts! any help is GREATLY > appreciated. If I can get it working I'll probably write a tutorial to > save a future baker this headache. firstly, make sure you have the correct enctype for your form: formTag('/controller/action/','post',array('enctype'=>'multipart/form-data')); ?> then, you can access the imageFile like so in your controller: $this->params['form']['imageFile'] not used the files component, so can't help with that, but the above should get you started. it's not very tricky really, once you know how cake works with form vars. hth jb jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
File uploads, image uploads
I want to populate a row in a database, and upload an image (into a directory, not the db) from the same form. I'd also like to grab the $_FILES[filename][name] param to go into the database. I have NO idea how to do this in Cake - no problem for me otherwise, but I don't even know where to begin when it comes to doing this w/Cake. (MVC Kung Fu is weak) Right now I've got a controller that functions fine to CRUD the data. I tried out the Files Component by Nicolas Cohen (put it in app/controllers/components as files.php) http://cakeforge.org/snippet/detail.php?type=snippet&id=7 added this to the view: file('imageFile') ?> and this to the controller: add() { yada yada... if ($this->Business->save($this->params['data'])) { if ($_FILES['imageFile']) { $this->Files->saveAs('imageFile', $imgId, WWW_ROOT . 'img'.DS.'uploads'.DS); } //cleanUpFields(effective_to_dt); $this->flash('Your listing has been saved.','/businesses'); } else { yada yada } } I get this error: Notice: Undefined index: imageFile in /myserver/app/controllers/businesses_controller.php on line 219 Is it trying to add imageFile to the db? FWIW, the upload dir is 777, and the form has the correct enctype. I've spent WAY too many hours on this one, searching the manual, wiki, group, lurking on IRC... it's driving me nuts! any help is GREATLY appreciated. If I can get it working I'll probably write a tutorial to save a future baker this headache. Thanks folks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---