有人可以建议我下一步该怎么做:
我有两个数据库表 - '产品'和' 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]);
}
我在这里假设这个函数出错了...... 我会感谢任何帮助。
答案 0 :(得分:0)
。,,
Upload::save();
$variable=upload::get_files();
foreach($variable as $img){
$img_name=$img['saved_as'];
}