Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
IniSizeFileException example
if
(
!
$moved
)
{
throw
new
FileException
(
sprintf
(
'Could not move the file "%s" to "%s" (%s).',
$this
->
getPathname
(
)
,
$target
,
strip_tags
(
$error
)
)
)
;
}
@
chmod
(
$target
, 0666 & ~
umask
(
)
)
;
return
$target
;
}
switch
(
$this
->error
)
{
case
\UPLOAD_ERR_INI_SIZE:
throw
new
IniSizeFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_FORM_SIZE:
throw
new
FormSizeFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_PARTIAL:
throw
new
PartialFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_NO_FILE:
throw
new
NoFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_CANT_WRITE:
throw
new
CannotWriteFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_NO_TMP_DIR:
throw
new
NoTmpDirFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_EXTENSION:
public
function
handleFileUpload
(
UploadedFileInterface
$uploadedFile
, array
$validators
=
[
]
, string
$destination
= 'temporary://', int
$replace
= FileSystemInterface::EXISTS_REPLACE
)
: FileUploadResult
{
$originalName
=
$uploadedFile
->
getClientOriginalName
(
)
;
if
(
!
$uploadedFile
->
isValid
(
)
)
{
switch
(
$uploadedFile
->
getError
(
)
)
{
case
\UPLOAD_ERR_INI_SIZE:
throw
new
IniSizeFileException
(
$uploadedFile
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_FORM_SIZE:
throw
new
FormSizeFileException
(
$uploadedFile
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_PARTIAL:
throw
new
PartialFileException
(
$uploadedFile
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_NO_FILE:
throw
new
NoFileException
(
$uploadedFile
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_CANT_WRITE:
if
(
!
$moved
)
{
throw
new
FileException
(
sprintf
(
'Could not move the file "%s" to "%s" (%s).',
$this
->
getPathname
(
)
,
$target
,
strip_tags
(
$error
)
)
)
;
}
@
chmod
(
$target
, 0666 & ~
umask
(
)
)
;
return
$target
;
}
switch
(
$this
->error
)
{
case
\UPLOAD_ERR_INI_SIZE:
throw
new
IniSizeFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_FORM_SIZE:
throw
new
FormSizeFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_PARTIAL:
throw
new
PartialFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_NO_FILE:
throw
new
NoFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_CANT_WRITE:
throw
new
CannotWriteFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_NO_TMP_DIR:
throw
new
NoTmpDirFileException
(
$this
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_EXTENSION: