Check out Miles J Uploader. http://www.milesj.me/resources/script/uploader-plugin
But that will check the file attempting upon submit. You can use js client side first to alert the user only jpg / gif first. Dave -----Original Message----- From: Tomfox Wiranata [mailto:[email protected]] Sent: August-01-10 1:10 PM To: CakePHP Subject: file upload: validate if file is image hi everyone, in relation,this seems not like a big deal (maybe cause i spent the whole weekend figuring out ajax), but somehow i dont get it done. when the user is selectig a file for an upload, i wanna make sure it's an image. so far i am checking in my controller if (($this->data['User']['name']['type'] != 'image/jpeg') || ($this->data['User']['name']['type'] != 'image/png') || ($this- >data['User']['name']['type'] != 'image/gif')) { $this->set('error','Du kannst nur Bilder hochladen(jpeg, png, gif)'); $this->render('previewprofileimage','ajax'); } else { process upload and resize } now what happens is, that even if the file is an image cake won't see it. i guess sth with the or operator is messed up??? that's the form btw: the .ctp-file <?php echo $form->create('User', array('name'=>'uploadProfileImageForm','id'=>'uploadProfileImageForm','type' =>'file')); echo $form->file('User'); ?> <button onClick="ajaxUpload(this.form,'editprofile','image_preview','<br / ><img src=\'../img/icons/loader.gif\' width=\'16\' height=\'16\' border=\'0\' />','Error in upload'); return false;" type="button">Hochladen</button> <?php echo $form->end(); ?> thx a lot :) Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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
