namespace
Encore
\
Admin
\
Form
\
Field
;
use
Symfony
\
Component
\
HttpFoundation
\
File
\
UploadedFile
;
class
Image
extends
File
use
ImageField
;
* {@inheritdoc}
protected
$view
=
'admin::form.file'
;
* Validation rules.
* @var string
protected
$rules
=
'image'
;
* @param array|UploadedFile $image
* @return string
public
function
prepare
(
$image
)
if
(
request
(
)
-
>
has
(
static
::
FILE_DELETE_FLAG
)
)
{
return
$this
-
>
destroy
(
)
;
$this
-
>
name
=
$this
-
>
getStoreName
(
$image
)
;
$this
-
>
callInterventionMethods
(
$image
-
>
getRealPath
(
)
)
;
$path
=
$this
-
>
uploadAndDeleteOriginal
(
$image
)
;
$this
-
>
uploadAndDeleteOriginalThumbnail
(
$image
)
;
return
"/upload/"
.
$path
;
————————————————
版权声明:本文为CSDN博主「哈佛凌晨」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:
blog.csdn.net/dyushuo6230/article/...
本作品采用
《CC 协议》
,转载必须注明作者和本文链接