Jump to content

Upload product images does not work


Superserver

Recommended Posts

Upload product images on the local XAMPP works fine!

 

The upload of product images on 1&1 server does not work. After upload a blank image subdirectory is created. The server does not report a PHP error.

 

(Directory permissions are correct and the upload of logos or other images works!)

 

Version der Server-Software: Apache

PHP-Version: 5.4.21

PrestaShop-Version: 1.6.0.1 (Alpha)

  • Like 1
Link to comment
Share on other sites

The permissions for the image folder are probably not sufficient for the server to upload images. Permission problems are often solved if you run php as cgi module. Not sure how 1&1 is handling this.

 

thank you, directory permissions are correct and the upload of logos or other images works! and yes, php runs as cgi.

I test the upload of images at a second installation on a different server now.

Link to comment
Share on other sites

The problem is this php error message:

 

[10-Dec-2013 20:30:25 Europe/Berlin] PHP Notice:  Undefined index: save_path in /.../shop/controllers/admin/AdminProductsController.php on line 3655

 

Is this a core error of the alpha version or did I miss something? This error is not here on the local xampp, getting on all 1 & 1 servers.

 

Link to comment
Share on other sites

Strange, the referenced line 3655 in AdminProductsController.php is

        if ($this->product_exists_in_shop)

 

Can you view the product you want to upload images to?

 

sorry, this is not correct, the first call of the undefined variable (save_path) is >>>

 

[AdminProductsController.php]

 

public function ajaxProcessaddProductImage()

{

...

if (!ImageManager::resize($file['save_path'], $new_path.'.'.$image->image_format)) <<< LINE 3655

{

 $file['error'] = Tools::displayError('An error occurred while copying image.');

 continue;

}

...

}

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

I have the bug isolated.
the problem: (the validation of upload file will not run)
you look at this >

post-735917-0-11237700-1386793988_thumb.jpg
post-735917-0-15721500-1386793998_thumb.jpg
post-735917-0-02768200-1386794009_thumb.jpg

the problem >

 

post-735917-0-81172800-1386794021_thumb.jpg

 

the resize function is called before the uploaded file is validated.

this error is the cause of my previous upload trouble
 
my english is not so good but the problem is found and I am tired after 12h presta core :blink:

 

When can I report errors for v1.6 Alpha in PrestaShop bug tracker?
Edited by Superserver (see edit history)
Link to comment
Share on other sites

Not sure if this is related, but I have read in another post that there is a bug in the imagemanager and your function in question refers to the image manager.

 

in classes/ImageManager.php line 132

there is a condition

if (!file_exists($src_file) || !filesize($src_file))

that is causing problems. Solution is commenting out the second part

if (!file_exists($src_file) /* || !filesize($src_file) */) 

Maybe worth a try ...

 

(or you could try if it works if you comment out line 3655 - 3659 in your AdminProductsController.php)

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

the bug has nothing to do with the file size !!!

the validation of upload file does not run correctly. I can upload all file types. This bug also give rise to problems with uploading images on my 1&1 server.

post-735917-0-11237700-1386793988_thumb.jpg post-735917-0-15721500-1386793998_thumb.jpg post-735917-0-02768200-1386794009_thumb.jpg post-735917-0-81172800-1386794021_thumb.jpg

I have done a simulation, it is tried first resize without running the file validation and check file type.
the correct way would be (anything else very unsafe!):
 
1 > product image upload 
2 > upload file validation (size, type, ...)
3.1 > is true then copy file into the presta image directory
3.2 > is false then return and show error message
4 > calling on success the resize function and more
 
the validation should be at the beginning without any further calls of functions. only then should follow more functional calls (eg resize).
 
I hope this information will pass on to the developer team ...
Edited by Superserver (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...