File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
app/code/Magento/PageBuilder/Controller/Adminhtml/ContentType/Image Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \PageBuilder \Controller \Adminhtml \ContentType \Image ;
7
7
8
- use Magento \Framework \Controller \ ResultFactory ;
8
+ use Magento \Framework \App \ Action \ HttpPostActionInterface ;
9
9
10
10
/**
11
11
* Class Upload
12
12
*/
13
- class Upload extends \Magento \Backend \App \Action
13
+ class Upload extends \Magento \Backend \App \Action implements HttpPostActionInterface
14
14
{
15
15
const UPLOAD_DIR = 'wysiwyg ' ;
16
16
@@ -94,7 +94,12 @@ public function execute()
94
94
$ fileUploader ->setAllowRenameFiles (true );
95
95
$ fileUploader ->setAllowedExtensions (['jpeg ' ,'jpg ' ,'png ' ,'gif ' ]);
96
96
$ fileUploader ->setAllowCreateFolders (true );
97
+
97
98
try {
99
+ if (!$ fileUploader ->checkMimeType (['image/png ' , 'image/jpeg ' , 'image/gif ' ])) {
100
+ throw new \Magento \Framework \Exception \LocalizedException (__ ('File validation failed. ' ));
101
+ }
102
+
98
103
$ result = $ fileUploader ->save ($ this ->getUploadDir ());
99
104
$ baseUrl = $ this ->storeManager ->getStore ()->getBaseUrl (\Magento \Framework \UrlInterface::URL_TYPE_MEDIA );
100
105
$ result ['id ' ] = $ this ->cmsWysiwygImages ->idEncode ($ result ['file ' ]);
You can’t perform that action at this time.
0 commit comments