我想在单独的列中将多个图像插入mysql数据库。我可以打印所有图像名称,但无法在插入列的变量中分离图像名称。我在单个提交中插入多个图像,因此当我尝试插入图像1,2,3,4时,print_r显示:“ 1.jpg2.jpg3.jpg4.jpg”。如何将每个* .jpg文件分隔为单独的变量?
[FORM]
<input type="file" name="product_image[]" value="" multiple="multiple" />
[CONTROLLER]
$insert = new Products();
if(is_array($this->request->getUploadedFiles())){
$image = $this->request->getUploadedFiles();
foreach($image as $file)
{
$file->moveTo('uploads/shop/' . $file->getName());
$myvars[] = $file->getName();
}
$insert->product_image1 = $myvars[0]);
$insert->product_image2 = $myvars[1]);
$insert->product_image3 = $myvars[2]);
$insert->product_image4 = $myvars[3]);
$insert->product_image5 = $myvars[4]);
$insert->save();
}
答案 0 :(得分:0)
$id = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');