Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
FormSizeFileException example
@
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:
throw
new
ExtensionFileException
(
$this
->
getErrorMessage
(
)
)
;
}
@
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:
throw
new
ExtensionFileException
(
$this
->
getErrorMessage
(
)
)
;
}
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:
throw
new
CannotWriteFileException
(
$uploadedFile
->
getErrorMessage
(
)
)
;
case
\UPLOAD_ERR_NO_TMP_DIR: