Здравствуйте, пытаюсь добавить фото в отзывы, помогите разобраться.
Вроде всё прописал, но не работает.
Сначала создал свойство у отзывов с типом файл, вывел его в XSL.
получилось что-то подобное:
<input name="property_246" type="file" id="property_246"/>
В $_FILES файл добавляется, массив выводится примерно такой:
array(5) { ["name"]=> string(23) "product-detail-mod6.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpg26f1s" ["error"]=> int(0) ["size"]=> int(91008) }
В форме отзывов сначала получил свойства
$oComment_Property_List = Core_Entity::factory('Shop_Comment_Property_List', $oShop->id);
$aProperties = $oComment_Property_List->Properties->findAll();
проверил, там были нужные.
Далее по аналогии как делал с магазином прописал:
$aFileData = Core_Array::getFiles("property_{$oProperty->id}", array());
if (is_array($aFileData) && isset($aFileData['name'])){
$sFileName = $aFileData['name'];
$oFileValue = $oProperty->createNewValue($oComment->id);
if (Core_File::isValidExtension($sFileName, array('JPG', 'JPEG', 'GIF', 'PNG')))
{
$oFileValue->file_name = Core_Str::stripTags($sFileName);
$oFileValue->file_small_name = Core_Str::stripTags($sFileName);
$oFileValue->save();
try {
$oComment_Property_List->createPropertyDir($oComment);
Core_Image::instance()->resizeImage($aFileData['tmp_name'], $oShop->image_large_max_width, $oShop->image_large_max_height, $oComment_Property_List->getDirPath($oComment) . $oComment_Property_List->getLargeFileName($oComment, $oFileValue, $sFileName));
$oFileValue->file = $oComment_Property_List->getLargeFileName($oComment, $oFileValue, $sFileName);
Core_Image::instance()->resizeImage($aFileData['tmp_name'], $oShop->image_small_max_width, $oShop->image_small_max_height, $oComment_Property_List->getDirPath($oComment) . $oComment_Property_List->getSmallFileName($oComment, $oFileValue, $sFileName));
$oFileValue->file_small = $oComment_Property_List->getSmallFileName($oComment, $oFileValue, $sFileName);
$oFileValue->save();
}
catch (Exception $e) {};
}
}
Направьте пожалуйста, куда копать.