So here is my problem. In the administration section of our Magento website, we need the ability to upload files from 2-500 MB each. I set my php.ini settings correctly, and all this is good with this requirement. But now I was asked to allow guests to download files from the external interface. Obviously, I do not want to give all strangers the opportunity to upload 500 MB of files. I searched around and could not find a decent direct answer to this problem.
So, how do you allow your administrator to continue to download extremely large files, while limiting third-party users to a smaller file size?
Here is my current solution:
public function saveAction()
{
$post = $this->getRequest()->getPost();
$helper = Mage::helper('my_module');
if ( $post ) {
try {
if ($_FILES['size'] >= 2000000) {
$errors[] = $helper->__('You have exceeded the max file size.');
$error = true;
}
if ($error) {
throw new Exception();
}
} catch (Exception $e) {
foreach($errors as $error) {
Mage::getSingleton('core/session')->addError($error);
}
$this->_redirect('*/*/*');
return;
}
}
}
This checks if the file exceeds the limit. If so, it throws an exception.
, , , - / . .