Jump to content

bug? the field mime is too long (32 chars max)


Recommended Posts

  • 5 months later...

Me too. I was trying to upload MS Office 2007 documents, e.g. a Word doc with a .docx extension, and it was being rejected every time.

Apparently the mime types for these documents can be up to 74 characters long!

Here's a list (source: http://www.bram.us/2007/05/25/office-2007-mime-types-for-iis/)

.docm,application/vnd.ms-word.document.macroEnabled.12
.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotm,application/vnd.ms-word.template.macroEnabled.12
.dotx,application/vnd.openxmlformats-officedocument.wordprocessingml.template
.potm,application/vnd.ms-powerpoint.template.macroEnabled.12
.potx,application/vnd.openxmlformats-officedocument.presentationml.template
.ppam,application/vnd.ms-powerpoint.addin.macroEnabled.12
.ppsm,application/vnd.ms-powerpoint.slideshow.macroEnabled.12
.ppsx,application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptm,application/vnd.ms-powerpoint.presentation.macroEnabled.12
.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation
.xlam,application/vnd.ms-excel.addin.macroEnabled.12
.xlsb,application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xlsm,application/vnd.ms-excel.sheet.macroEnabled.12
.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltm,application/vnd.ms-excel.template.macroEnabled.12
.xltx,application/vnd.openxmlformats-officedocument.spreadsheetml.template

To get it working, I had to edit the ps_attachment table and set the field length to 74.
Next, open up the Attachment.php file (it's in the classes dir) and edit line 26 where it says:

protected    $fieldsSize = array('file' => 40, 'mime' => 32);



just change this to

protected    $fieldsSize = array('file' => 40, 'mime' =>74);



and you should be good to go!

Link to comment
Share on other sites

  • 2 years later...

Hi I have got crack to increse attachment name length for prestashop version 1.5.4

 

STEP 1

Go to classes/Attachment.php

 

find the code near line no 50

 

'name' =>array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),

 

Replacede with

 

'name' =>array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),

 

 

 

STEP 2

go to

controllers\admin\AdminProductsController.php

 

 

 

Find the function processAddAttachments()

inside that fuction find code near line no 463

 

elseif (Tools::strlen(Tools::getValue('attachment_name_'.(int)($language['id_lang']))) > 32)

$this->errors[] = sprintf(Tools::displayError('The name is too long (%d chars max).'), 32);

 

 

Replace width

 

elseif (Tools::strlen(Tools::getValue('attachment_name_'.(int)($language['id_lang']))) >128)

$this->errors[] = sprintf(Tools::displayError('The name is too long (%d chars max).'), 128);

 

 

STEP 3

 

Open database table ps_attachment_lang

 

change name field varchar(32) to varchar(128)

  • Like 1
Link to comment
Share on other sites

  • 10 months later...
  • 4 weeks later...
  • 8 months later...
  • 1 year later...

Its the same, except for STEP 2

 

 

STEP 2
go to
controllers\admin\AdminProductsController.php

 

at line 601 to 604 :

 

 if (!Validate::isGenericName($name)) {
 $_FILES['attachment_file']['error'][] = sprintf(Tools::displayError('Invalid name for %s language'), $language['name']);
  } elseif (Tools::strlen($name) > 32) {
  $_FILES['attachment_file']['error'][] = sprintf(Tools::displayError('The name for %1s language is too long (%2d chars max).'), $language['name'], 32);

 

change to :

 

 if (!Validate::isGenericName($name)) {
 $_FILES['attachment_file']['error'][] = sprintf(Tools::displayError('Invalid name for %s language'), $language['name']);
  } elseif (Tools::strlen($name) > 128) {
  $_FILES['attachment_file']['error'][] = sprintf(Tools::displayError('The name for %1s language is too long (%2d chars max).'), $language['name'], 128);

 

That worket for me!
 

Edited by markovo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...