Jump to content

Product Customization Field Image Upload doesn't work


Recommended Posts

Hi,

i've a problem with prestashop customization field upload because where customers upload there's image and click save the page refresh with a corrupt thumbnail link like as the screenshot below:

post-818953-0-25208400-1421053166_thumb.jpg

 

When i click on this link and select "open image as a new tab" i see the following url and a 404 page:

post-818953-0-88402400-1421053228_thumb.jpg

 

On my server (winserver2008r2) in the upload folder i find the file without extension.

 

Where i can fix this problem?

 

Thanks in advance

 

Regards

Link to comment
Share on other sites

Hi,

i've opened productcontroller.php and i've found following code:

protected function pictureUpload()
	{
		if (!$field_ids = $this->product->getCustomizationFieldIds())
			return false;
		$authorized_file_fields = array();
		foreach ($field_ids as $field_id)
			if ($field_id['type'] == Product::CUSTOMIZE_FILE)
				$authorized_file_fields[(int)$field_id['id_customization_field']] = 'file'.(int)$field_id['id_customization_field'];
		$indexes = array_flip($authorized_file_fields);
		foreach ($_FILES as $field_name => $file)
			if (in_array($field_name, $authorized_file_fields) && isset($file['tmp_name']) && !empty($file['tmp_name']))
			{
				$file_name = md5(uniqid(rand(), true));
				if ($error = ImageManager::validateUpload($file, (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE')))
					$this->errors[] = $error;

				$product_picture_width = (int)Configuration::get('PS_PRODUCT_PICTURE_WIDTH');
				$product_picture_height = (int)Configuration::get('PS_PRODUCT_PICTURE_HEIGHT');
				$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
				if ($error || (!$tmp_name || !move_uploaded_file($file['tmp_name'], $tmp_name)))
					return false;
				/* Original file */
				if (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name))
					$this->errors[] = Tools::displayError('An error occurred during the image upload process.');
				/* A smaller one */
				elseif (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name.'_small', $product_picture_width, $product_picture_height))
					$this->errors[] = Tools::displayError('An error occurred during the image upload process.');
				elseif (!chmod(_PS_UPLOAD_DIR_.$file_name, 0777) || !chmod(_PS_UPLOAD_DIR_.$file_name.'_small', 0777))
					$this->errors[] = Tools::displayError('An error occurred during the image upload process.');
				else
					$this->context->cart->addPictureToProduct($this->product->id, $indexes[$field_name], Product::CUSTOMIZE_FILE, $file_name);
				unlink($tmp_name);
			}
		return true;
	}
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

Hello there. I'm having the same error in cloud too. When a new image is uploaded into the product category, it appears in blank. However, inside the product listing, the miniature is displaying correctly. But, on the shop itself it doesn't show.

Link to comment
Share on other sites

  • 4 weeks later...

I've got the same problem, however it can work as the site yourphotojigsaw.co.uk demonstrates (not my site).  I think he had the same problem and noted it on the forum but I don't think he told us how he fixed it.  This is important to me too as all my customers have to upload their photos.  Am going to whinge to prestashop - it has to be a bug.

Link to comment
Share on other sites

Oh, I'm sorry I totally missed answering this thread. I meant that you might try going to Preferences -> Images, select the image type that is not displaying, and regenerate (at the very bottom). Also, if you use a custom template, make sure it references the correct image type name

Link to comment
Share on other sites

This has been listed as a bug back in January it is in the list of bugs and its reference is PSCX-4360 and its title is "

Images uploaded in customization does not appear in cart"

Please log in to the bug reporter and add your vote and comment.  Then perhaps it will shoot up the list of priorities.  If it has been listed since January and assigned to a programmer to sort out but nothing hs happened it looks as though it needs more weight behind it.  I urge every member of the forum to vote for this one!

 

To log in to the bug reporter:

 

-www.prestashop.com

-then at the very bottom of the page at the end of the last column under company click "contact us"

-select "You found a bug on PrestaShop Cloud or PrestaShop download."

-this brings you to the System Dashboard with CREATE highlighted in blue.

-selecting this brings up a box "Create Issue" which has the line "Have you searched on this issue to avoid duplicates (click here)?

- click here which brings up the search window.

- search string "customisation image" brings up a short list of which our baby PSCX 4360  Images uploaded in customisation...  is second.  Select this.

 

- Add your vote comment etc.  I note now that Gregory says that the reporter has a 500 error while consulting the image and will look into that.  However it is still a bug.  Why has the poor sap got a 500 error on his image - all he has done is load up Prestashop to make his shop - should not have to delve into the mechanics of server php or whatever to have his customers send their images for T-shirts.

 

- Lets get some weight behind this - the customisation implementation and the way it displays at bottom of the product page with the save button - is scruffy anyway.

 

Thanks to all who have addressed this on the forums,

Andrew

Link to comment
Share on other sites

Hello Nemo,

  Have tried a number of things but with no avail.  Have loaded up a fresh PrestaShop and added a 1 file customisation to a t-shirt.  Obviously have done everything right, ie save button before add to basket button.  The bug instantly manifested itself by showing an empty line for the uploaded file in the shopping cart summary.

  Have tested this on my embrionic sit some days ago and the file does come through to the back office.  However this is useless if the customer experience is such that he has no confidence or confirmation that the file has uploaded has been accepted.

 

  Am just about to investigate the debug/errpr 500 possibility suggested on the bug report.

  Andrew

Link to comment
Share on other sites

Hi Nemo,

  It's not a standard or product image problem,  they all show up OK.  It's when a customer uploads an image as part of the PrestaShop customisation facility for a product that the problem occurs.  The image does not show up in the shopping cart summary as it should.  I believe that the relevant code is in the shopping-cart-product-line.tpl template.  This code points to the location of the uploaded file but the uploaded file does not display in the summary and if you down load it and try to display it it appears to be junk so it is probably encoded.

 

  To demonstrate the problem simply add a file customisation to a product in the BO.  Then select the product in the FO and upload a file.  Look at the shopping cart summary and you will see that there is no record of the image having been uploaded. 

 

  If you are going to address this it would be nice to know how to retrieve the original filename of the uploaded file so that it can be displayed next to the image on the shopping cart summary.

 

  The file upload mechanism with its long coded filenames is far from clear - can anyone shed any light on it?

Link to comment
Share on other sites

The files live in the upoad directory (called upload) but are assigned a coded key.  In my remote server everything has 755 permissions and cannot see an obvious file permission difficulty - however would love to be proved wrong if it solves the problem.  Anyone worked out the file upload story, it sees that the files in the upload directory are coded in some way and cannot be directly downloaded with ftp and viewed.  Anyone worked out how this all works?  I would like to put the file name on the invoice and the shopping cart summary.  Where can I retrieve the file name - I have found the customisation code in the product-line.tpl file?

 

Some people have got it to work - be good if they noted down how they solved it to we can try it.

Link to comment
Share on other sites

Have finally solved it - with a lot of help from the chap who runs the warehouse prestashop them at iqit-commerce.com and the technical support at one.com.

 

The answer is:

in the .htaccess file that lives in the prestashop/upload directory there is a line at the end 'php_flag engine off'  simply remove this line.

 

Hope this helps - it has certainly helped me!

 

Now what I would really like to do now is add the name of the image file under or along side the image.  Anyone have any ideas?  The file to tackle is the shopping-cart-product-line.tpl and the coded filename in upload is available but I cannot see how to get the original filename.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 5 months later...
  • 3 weeks later...
  • 3 months later...
  • 1 year later...

Hi! I still have this same issue, ie. the upload of the customisation image file seems to work - it's in the uploads folder and I can download and see it fine via FTP. However, as part of the user experience during the pruchasing process, the thumbnail shows up as a broken image icon. If I right-click on it to Open in a New Tab, I get a message 

Forbidden

You don't have permission to access /upload/f2cf544d8c2598888c7ec77c06f7e72f_small on this server.

 

I tried changing file permissions even right up to 777 but this makes no difference. I don't have the "php_flag engine off" in the .htaccess file in the uploads folder. Does anybody have any other ideas? This is the .htaccessfile:

 

deny from all
<Files ~ "(?i)^.*\.(jpg|jpeg|gif|png|bmp|pdf)$">
order deny,allow
allow from all
</Files>
 

 

If I am a customer trying to buy a product, I certainly would not proceed as it looks like my file was not uploaded. Any ideas? thanks!

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

  • 2 months later...

Hi! I still have this same issue, ie. the upload of the customisation image file seems to work - it's in the uploads folder and I can download and see it fine via FTP. However, as part of the user experience during the pruchasing process, the thumbnail shows up as a broken image icon. If I right-click on it to Open in a New Tab, I get a message 

Forbidden

You don't have permission to access /upload/f2cf544d8c2598888c7ec77c06f7e72f_small on this server.

 

I tried changing file permissions even right up to 777 but this makes no difference. I don't have the "php_flag engine off" in the .htaccess file in the uploads folder. Does anybody have any other ideas? This is the .htaccessfile:

 

deny from all
<Files ~ "(?i)^.*\.(jpg|jpeg|gif|png|bmp|pdf)$">
order deny,allow
allow from all
</Files>
 

 

If I am a customer trying to buy a product, I certainly would not proceed as it looks like my file was not uploaded. Any ideas? thanks!

 

 

hello,you may try to add the extension to the small image file

 

elseif (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name.'_small.jpg', $product_picture_width, $product_picture_height))

                    $this->errors[] = Tools::displayError('An error occurred during the image upload process.');

                elseif (!chmod(_PS_UPLOAD_DIR_.$file_name, 0777) || !chmod(_PS_UPLOAD_DIR_.$file_name.'_small.jpg', 0777))

                    $this->errors[] = Tools::displayError('An error occurred during the image upload process.');

                else

Link to comment
Share on other sites

×
×
  • Create New...