有人可以建议我下一步该怎么做:
我有两个数据库表 - 'products' 和 'products_photo' 我想添加我的产品以更新我的产品表和有关上传照片的信息以保存到单独的表中。
我上传了照片,关于产品的表格已正确填写,但我的表格products_photos
是空的。
我的 controler_product 包含
// Custom configuration for this upload
$config = array(
'path' => DOCROOT.DS.'images',
'randomize' => true,
'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
);
Upload::process($config);
// if a valid file is passed than the function will save, or if its not empty
if (Upload::is_valid())
{
// save them according to the config
Upload::save();
//if you want to save to tha database lets grab the file name
Model_Products_Photo::add(Upload::get_files());
} // and process any errors
foreach (Upload::get_errors() as $file)
{
// $file is an array with all file information,
// $file contains an array of all error occurred
// each array element is an an array containing 'error' and 'message'
}
我的模型products_photo
包含
public static function add($file)
{ print_r($file);
Model_Products_Photo::forge( $file[0]);
}
我假设这个函数有问题......我会感谢你的帮助。