Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Product custom option “File”. Set max upload file size
 
OlivertAr
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2008-06-19
Buenos Aires - Argentine
 

Be possible add this feature in Magento core?
Here are the changes that I’ve researched, is a very basic version.

Thanks

Magento 1.3.0
Product custom option “File”, Set max upload file size

core/Mage/Catalog/Model/product/Option/Type/File.php
In line 106
/* Validate size */
$_sizes[’max’] = $option->getFileSize();
$_sizes[’min’] = 1;
if(!empty($_sizes[’max’])){
$upload->addValidator(’FilesSize’, true, $_sizes);
}
/* Validate size */

---------------
core/Mage/Catalog/Model/Product/Option.php
In line 262
$this->setData(’file_size’, ‘0’);

---------------
core/Mage/Catalog/Model/Product/Edit/Tab/Option/Options.php
In line 235
$value[’file_size’] = $option->getFileSize();

-------------------
app/design/adminhtml/default/default/template/catalog/product/edit/options/type/file.phtml
In line 36
‘<th class="last"><?php echo Mage::helper('catalog')->__('Maximum File Size') ?></th>’+

In line 44
‘<td><input class="input-text" type="text" name="product[options][{{option_id}}][file_size]" value="{{file_size}}"> <?php echo Mage::helper('catalog')->__('bytes') ?></td>’+

-----------------------
In DB
ALTER TABLE `catalog_product_option` ADD `file_size` INT( 11 ) NOT NULL AFTER `file_extension` ;

Oliver

Image Attachments
max_file_size.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
Sébastien Cramatte
Jr. Member
 
Avatar
Total Posts:  21
Joined:  2007-09-04
Murcia, Spain
 

Hi,

I’m running Magent 1.3.2.4 and I’m not able to find file where I should add this line

$value[’file_size’] = $option->getFileSize();

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

Is meant to be

mage/adminhtml/catalog/model/product/edit/tab/options/option.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jasper van den Ham
Jr. Member
 
Total Posts:  10
Joined:  2009-08-20
 

Does anybody know how this works in 1.4?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alleytree
Jr. Member
 
Total Posts:  2
Joined:  2010-06-10
 

What would you change in order to place a MINIMUM IMAGE SIZE on the uploaded file?

I follow most everything in this example, but I’m not comfortable enough in my PHP skills to craft new code from scratch. Is there a third-party extension that makes these kinds of adjustments easier?

Thanks for this very thorough example!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top