本文整理匯總了PHP中Images::getContentHash方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::getContentHash方法的具體用法?PHP Images::getContentHash怎麽用?PHP Images::getContentHash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::getContentHash方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doSaveMedia
public function doSaveMedia($v)
{
if ($v == null) {
$image = $this->getImagePath();
if ($this->isNew) {
$content = file_get_contents(sfConfig::get('sf_root_dir') . '/public_html' . $image);
$size = getimagesize(sfConfig::get('sf_root_dir') . '/public_html' . $image);
} else {
return $this->getObject()->getImagesId();
}
} else {
$content = file_get_contents($v->getTempName());
$size = getimagesize($v->getTempName());
}
$hash = md5($content);
$criteria = new Criteria();
$criteria->add(ImagesPeer::CONTENT_HASH, $hash);
$obj = ImagesPeer::doSelectOne($criteria);
try {
if (empty($obj)) {
$obj = new Images();
$obj->setNameDownloadedFile($v->getOriginalName())->setNameFileForPage($v->getOriginalName())->setTypeImg($v->getType())->setHeight($size[2])->setWidth($size[1])->setContentHash($hash . '.jpg')->setContent(base64_encode($content))->setCreatedAt(date("Y-m-d H:i"))->setUpdatedAt(date("Y-m-d H:i"))->save();
}
} catch (Exception $e) {
echo "stdfdfdfdfrt";
die;
}
$criteria = new Criteria();
$criteria->add(ImagesPeer::CONTENT_HASH, $obj->getContentHash());
$obj = ImagesPeer::doSelectOne($criteria);
return $obj->getId();
}
示例2: doSaveMedia
public function doSaveMedia($v)
{
//var_dump($v);die;
$content = file_get_contents($v['tmp_name']);
$hash = md5($content);
$size = getimagesize($v['tmp_name']);
$criteria = new Criteria();
$criteria->add(ImagesPeer::CONTENT_HASH, $hash);
$obj = ImagesPeer::doSelectOne($criteria);
try {
if (empty($obj)) {
$obj = new Images();
$obj->setNameDownloadedFile($v['name'])->setTypeImg($v['type'])->setHeight($size[2])->setWidth($size[1])->setContentHash($hash . '.jpg')->setContent(base64_encode($content))->setCreatedAt(date("Y-m-d H:i"))->setUpdatedAt(date("Y-m-d H:i"))->save();
}
} catch (Exception $e) {
echo "stdfdfdfdfrt";
die;
}
$criteria = new Criteria();
$criteria->add(ImagesPeer::CONTENT_HASH, $obj->getContentHash());
$obj = ImagesPeer::doSelectOne($criteria);
// var_dump($obj->getId());die;
return $obj->getId();
}