Yii multi-file Upload processing in the controller do you need to call the myFileHandler method that only has file upload fields?
12345678910 |
PublicfunctionactionIndex (){................ $ model = $ this-> myFileHandler ($ model, array ('logo ', 'emailus _ img', 'emailus _ img_hover ', 'more _ img ', 'More _ img_hover ', 'gomo _ logo', 'mobile _ phone_img ', 'animate _ on_mobile_img', 'animate _ above_text_img ', 'animate _ under_text_img ', 'bottom _ right_img '));..............} |
?
123456789101112131415 |
PublicfunctionmyFileHandler ($ model, $ imgFieldNameArr) {foreach ($ imgFieldNameArras $ attribute) {$ instance = CUploadedFile: getInstance ($ model, $ attribute); if ($ instance) {$ fullImgName = time (). '_'. $ attribute. '. '. $ instance-> getExtensionName (); $ fullImgSource = Yii: getPathOfAlias ('webroot '). '/media/images /'. $ fullImgName; $ instance-> saveAs ($ fullImgSource); $ model-> $ attribute = $ fullImgName ;}} return $ model; // return model with updated file path} |
Hope this tips will help you.