chris.paschen
Chris Paschen
Due to several different reasons (way too complex to explain) we need to manually review the uploads to several file upload elements.
One of the things that we need to check is to make sure the file size being upload is not over a certain limit.
I'm calling the following code within a function of the form with a PHP onBeforeProcess:
[I originally just tried to use the getSize() directly on $fileInfo but got nothing there.]
However, no matter what I do I can't actually get the size of the file.
I've also tried running this after the entry has been saved (onAfterProcess) with same results.
Is there any other way to get the size of the file that someone is trying to upload?
(unforutnately using validations or the in-built element size limits won't work for this situation).
Any ideas why the above code isn't working?
One of the things that we need to check is to make sure the file size being upload is not over a certain limit.
I'm calling the following code within a function of the form with a PHP onBeforeProcess:
Code:
$fileCoverFile = $formModel->getElementData('ked_books_books___upload_book_cover_image');
$fileInfo = new SplFileInfo($fileCoverFile);
$extension = $fileInfo->getExtension();
$filename = $fileInfo->getFilename();
$validFileType = 0;
$fileAbsolute = $fileInfo->getRealPath();
$absoluteFile = new SplFileInfo($fileAbsolute);
$size = $absoluteFile->getSize();
However, no matter what I do I can't actually get the size of the file.
I've also tried running this after the entry has been saved (onAfterProcess) with same results.
Is there any other way to get the size of the file that someone is trying to upload?
(unforutnately using validations or the in-built element size limits won't work for this situation).
Any ideas why the above code isn't working?