Jump to content

Uploading products images issues


Recommended Posts

Hi everybody,

 

I'm having issues uploading product images, for example when I try to upload an image and then click on upload button, it does nothing. When I try to exit from the tab, it says that i have services running, and all changes could not be saved. When I exit it shows on the footer an error "undefined". I think it's a database problem or code problem, because when I try to export the csv file in the image column links the image to "http://www.myweb.com/img/p/0.jpg". And if I try to import the csv that i have just exported, it makes no changes.

 

Please, help me, i'm desesperated, i have products and I don't know how to save all the work and fix this problem.

 

Best regards, centrobolsos

 

EDIT: I FIXED THE PROBLEM!

 

There was an issue with FileUploader.php, in line 166 $temp = tmpfile(); missing.

Edited by centrobolsos (see edit history)
  • Like 1
Link to comment
Share on other sites

Hello, I'm having the same problem, line 166 is that one right?

 

$image = new Image();
$image->id_product = (int)($product->id);
$image->position = Image::getHighestPosition($product->id) + 1;   <<<<<<
$legends = Tools::getValue('legend');
if (is_array($legends))
 
can you copy line 160 to 166 so i can check if mine is the same?
 
Thanks =)
Link to comment
Share on other sites

 

Hello, I'm having the same problem, line 166 is that one right?

 

$image = new Image();
$image->id_product = (int)($product->id);
$image->position = Image::getHighestPosition($product->id) + 1;   <<<<<<
$legends = Tools::getValue('legend');
if (is_array($legends))
 
can you copy line 160 to 166 so i can check if mine is the same?
 
Thanks =)

 

Hello, i'll copy and paste the entire function (working):

 

 

public function upload($path)

    {

 

        $target = fopen($path, 'w');

        $temp = tmpfile();    /* <-- The missing line that makes the error (my case) */

 

        $realSize = stream_copy_to_stream($input, $target);

        if ($realSize != $this->getSize())

            return false;

 

        fclose($input);

        fclose($target);

 

        return true;

    }

 

 

 

Best regards, Centrobolsos

  • Like 1
Link to comment
Share on other sites

I'm have the exact same problem, however, I'm no programmer - and your posts are way out of my league.  However, I'd still appreciate a simple, step by step procedure on how to fix this error.  When I press the "upload an image" button to add a picture for my product...it does nothing.  Completely nothing.  I've added products for months - never a problem until now.  I would so appreciate some assistance...as this is costing our company money.

 

Thanks so much!!  B)

Link to comment
Share on other sites

 

There was an issue with FileUploader.php, in line 166 $temp = tmpfile(); missing.

 

in what folder this file is located? I searched but apparently is missing. I just upgraded to 1.5.6.1 but it worked for some time after the upgrade before stopping...

Link to comment
Share on other sites

Hi, everyone. I'm having a similar problem with my Prestashop store after updating to 1.5.6.1. When I try to upload a product image from inside the Images tab under Catalog - Products, the "Undefined" error bar appears.

 

The console shows my webserver is returning the 403 Forbidden error. So this looks like a problem with permissions. I've tried the fix to FileUploader.php given above, and have tried disabling the Apache mod_security either by changes to .htaccess and/or turning off the switch in Prestashop back office. None of these cured the problem. I had no trouble until after the update.

 

According to my console, Prestashop is attempting to upload the picture by posting to ajax-tab.php in the admin folder. Interestingly, I am able to copy the post URL, including my latest security token into the Firefox / Chrome add-on "Poster", and manually post the file, it works! Using Post, the image is processed and saved by Prestashop and shows up in all the right places. But posting it using the Prestashop GUI will not work at all - always the undefined error resulting from the  "Forbidden" 403. Posting category pictures works fine, which apparently posts with a completely different method. Note that the manual posting method using Chrome Post works even with mod_security fully enabled.

 

Any thoughts? Thanks for any suggestions. I've read older related posts and bug reports about this issue already. Thanks!!

 

My configuration info is below in case it's useful. I know my browser is ancient; I had the same trouble with IE under Windows 7.

Server information

Server information: Linux #1 SMP Wed Apr 3 12:05:42 EEST 2013 x86_64

Server software version: Apache

PHP version: 5.3.26

Memory limit: 128M

Max execution time: 30

Database information

MySQL version: 5.1.70-cll

MySQL engine: InnoDB

Tables prefix: ps_

Store information

PrestaShop version: 1.5.6.1

Shop URL: https://www.donleyviolins.net/shopping/

Current theme in use: theme1

Mail configuration

Mail method: You are using the PHP mail function.

Your information

Your web browser: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0

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

I'm have the exact same problem, however, I'm no programmer - and your posts are way out of my league.  However, I'd still appreciate a simple, step by step procedure on how to fix this error.  When I press the "upload an image" button to add a picture for my product...it does nothing.  Completely nothing.  I've added products for months - never a problem until now.  I would so appreciate some assistance...as this is costing our company money.

 

Thanks so much!!  B)

Have you got acess to the ftp? In that case you have to find the FileUpload.php and then double click it and open with any text editor.

Link to comment
Share on other sites

Thanks for the suggestion, Centrobolsos regarding uploading FileManager.php from the Prestashop source code. I tried that but it did not help. I don't see any difference between the FileManager.php I downloaded from Prestashop, and the same file I used in the Softaculous package to update my installation. Of course there should not be any difference, but it was worth a try.

 

The new FileManager.php does not include the edit discussed earlier in this thread, and this edit made no difference on my system. Uploading images through the Prestashop GUI returns "undefined" based on a 403-Forbidden error, but manually uploading the images using Poster works fine, regardless of the Line 166 edit on FileManager.php.

 

I wonder if Brighteyes was having trouble with the internet connection during download. I have also noticed that a loss of internet service during image upload will cause Prestashop to throw the "undefined" error, so it's important to look at the webconsole to see what error is being returned by the server.

 

So if anyone wants to guess what's going on here, we're still open for your ideas! Thanks!!

Link to comment
Share on other sites

Thanks for the suggestions...

 

I have spent all day on this, it's nothing to do with internet connection. 

 

The web console throws a 406 error (see attachment).

 

This happens in all browsers both Mac & PC. I've turned off mod security i Prestsahop and nothing.

 

It's not server based because my other 4 shops using 1.5.6 work fine all on the same server.

 

This (for me) is unique to 1.5.6.1 and is specifically affecting product image uploads.

 

I can't wait for Prestashop as this is holding up my project. I need to re create this site from scratch using 1.5.6 and just avoid upgrading.

 

 

post-382157-0-22805900-1385401282_thumb.png

Link to comment
Share on other sites

Try change js/fileuploader.js line 1075 to 

 

 xhr.setRequestHeader("Content-Type", "application/octet-stream");
 xhr.setRequestHeader("processData", false);
 
its work for me.
 
Edited by zainoz.zaini (see edit history)
  • Like 4
Link to comment
Share on other sites

 

Try change js/fileuploader.js line 1075 to 

 

 xhr.setRequestHeader("Content-Type", "application/octet-stream");
 xhr.setRequestHeader("processData", false);
 
its work for me.
 

 

Works for me also!!!

 

Thanks

Link to comment
Share on other sites

Thanks, zainoz.zaini! That fix to fileuploader.js worked for me also! I had not seen Roussac's post on GitHub documenting the change. That was definitely the problem for me, and now it's fixed. And I have mod_security fully enabled. So if this works for Brighteyes also, we can mark this one as "Solved" thanks to Roussac and zainoz.zaini! It's so nice to see the little green bar that tells you the image upload was a success!

Link to comment
Share on other sites

Karikolraj, if you can monitor with a web console while you try to upload the image and post the error returned by the server, it will help us help you. Prestashop can throw the "undefined" error for many reasons. Can you upload category images with no problem?

Link to comment
Share on other sites

I'm using 1.5.6.0 and used Autoupdate, now I can upload image for categories but for products I got same error "undefined" below is the error I received in browser consol:

 

[01:23:07.868] POST http://xxxx.com/admin123/ajax-tab.php?id_product=1&id_category=0&token=16e2bbac185d40c092d96971f299e597&tab=AdminProducts&action=addImage&ajax=1&legend%5B1%5D=iPod+Nano&legend%5B2%5D=iPod+Nano&qqfile=micoucs.jpg [HTTP/1.1 404 Not Found 5200ms]

 

pls help

 

 

my problem also solved with cleaning the cache

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

Karikolraj, if you can monitor with a web console while you try to upload the image and post the error returned by the server, it will help us help you. Prestashop can throw the "undefined" error for many reasons. Can you upload category images with no problem?

Some how it worked now. I cleared my browser cache and tried with the changes given, it worked. 

 

Thanks

Link to comment
Share on other sites

 

Try change js/fileuploader.js line 1075 to 

 

 xhr.setRequestHeader("Content-Type", "application/octet-stream");
 xhr.setRequestHeader("processData", false);
 
its work for me.
 

 

 

Works for me (1.5.6.1)!

Thanks!

Link to comment
Share on other sites

Same problem for me!

 

Is anybody working on this topic?

 

Is there any way to upload in some other (for example "manual") way?

 

(PS. Clearing cache and adding presented lines did not work for me)

 

EDIT:

Ok, it works after deleting cache but not under Opera browser

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

Same problem for me!

 

Is anybody working on this topic?

 

Is there any way to upload in some other (for example "manual") way?

 

(PS. Clearing cache and adding presented lines did not work for me)

 

EDIT:

Ok, it works after deleting cache but not under Opera browser

 

Hi, yes you can upload images manually by .xls

 

You have to upload the images in folders by FTP and then type the URL in the .xls document and import it

Link to comment
Share on other sites

 

Try change js/fileuploader.js line 1075 to 

 

 xhr.setRequestHeader("Content-Type", "application/octet-stream");
 xhr.setRequestHeader("processData", false);
 
its work for me.
 

 

 

This work for me (presta 1.5.6.1)

  • Like 1
Link to comment
Share on other sites

to change fileuploader.js line 1075 worked for me too...

 

just to understand: what does the change mean for non-professionals?  ;)

 

When data that has been entered into HTML forms is submitted, the form field names and values are encoded and sent to the server in an HTTP request message using method GET or POST.

The header declared as application/x-www-form-urlencoded -  is used to encode percent-encoding rules, with a number of modifications such as newline normalization and replacing spaces with "+" instead of "%20".

Since we want to send picture (encoded as base64 that represent binary data) then it embedded into the header, so the request will not acceptable because response entities which have content characteristics not acceptable according to the accept headers sent in the request (error 406).

Thus, the content type has to be specified. The application/octet-stream in the header declares is an arbitrary binary data is contained from the request. 

Edited by zainoz.zaini (see edit history)
Link to comment
Share on other sites

I tried the above methods, still no luck :(( still not able to upload any product images

 

what i did is,

highlight the 1075 code in js/fileuploader. just highlight the code, and replace with  

 

 

xhr.setRequestHeader("Content-Type", "application/octet-stream");

 xhr.setRequestHeader("processData", false);

and save it, with doing nothing else. 

 

hope this will help you.

 

make exactly like this

from line 1074 until 1079

 

1074 xhr.open("POST", queryString, true);
1075 xhr.setRequestHeader("Content-Type", "application/octet-stream");
1076 xhr.setRequestHeader("processData", false);
1077 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1078 xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
1079 xhr.send(file);
Edited by afiqtech (see edit history)
Link to comment
Share on other sites

I tried the above methods, still no luck :(( still not able to upload any product images

 
change the code found in directory js/fileuploader.js from line 1074 until 1079. make it exactly like this
 
        1074 xhr.open("POST", queryString, true);
        1075 xhr.setRequestHeader("Content-Type", "application/octet-stream");
        1076 xhr.setRequestHeader("processData", false);
        1077 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        1078 xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
        1079 xhr.send(file);
 
get the attachment below, hope get it clearly for you. 

 

post-736015-0-79579900-1386607162_thumb.png

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

I have got an another solution.... :)

 

I tried every method discussed here but i failed to recover my problem.....

 

By 2 days efort finally I got another solution which disscussed below....

 

My domain is a subdomain like "shop.mydomain.com" and my prestashop software was installed in this domain folder "shop".

I explore that when I use my url like "shop.mydomain.com/admin" (default) it did not work but when I use my url like "mydomain.com/shop/adminfolder" then it work without any change of the software/program.

 

If you are using a subdomain, I suggest you to use the url like "yourdomain.com/subdomain-name/adminfolder" only for uploading the product image. Otherwise use default url.

 

Now I am using the version 1.5.6.1 by tihs method without any "undefined" error... :D

 

NB: After your login the software will show you a warning message to change your domain. Please don't any response of this warning message.

Edited by amanullah.en (see edit history)
Link to comment
Share on other sites

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

I have got an another solution.... :)

 

I tried every method discussed here but i failed to recover my problem.....

 

By 2 days efort finally I got another solution which disscussed below....

 

My domain is a subdomain like "shop.mydomain.com" and my prestashop software was installed in this domain folder "shop".

I explore that when I use my url like "shop.mydomain.com/admin" (default) it did not work but when I use my url like "mydomain.com/shop/adminfolder" then it work without any change of the software/program.

 

If you are using a subdomain, I suggest you to use the url like "yourdomain.com/subdomain-name/adminfolder" only for uploading the product image. Otherwise use default url.

 

Now I am using the version 1.5.6.1 by tihs method without any "undefined" error... :D

 

NB: After your login the software will show you a warning message to change your domain. Please don't any response of this warning message.

I tried all above this post and it didn't work, but this was the problem, now is ok... Thank you amanullah.en !! 

Link to comment
Share on other sites

 

 
change the code found in directory js/fileuploader.js from line 1074 until 1079. make it exactly like this
 
        1074 xhr.open("POST", queryString, true);
        1075 xhr.setRequestHeader("Content-Type", "application/octet-stream");
        1076 xhr.setRequestHeader("processData", false);
        1077 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        1078 xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
        1079 xhr.send(file);
 
get the attachment below, hope get it clearly for you. 

 

 

 

Fresh install of 1.5.6.2 today (24.01.2014)

 

my fileuploader.js:

 

1074        xhr.open("POST", queryString, true);
1075       xhr.setRequestHeader("Content-Type", "application/octet-stream");
1076        xhr.setRequestHeader("processData", false);
1077        xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1078       xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
1079        xhr.send(file);
 
 
DOESNT WORK !!!
 
Same issue on two 1.5.5.0 shops on two different servers
 
I manage those shops with eMagic Manager for PrestaShop, but i think Presta Team will have to solve this problem
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hello,

I have an 1.5.6.2 PrestaShop fresh install.

I tried all methods mentionned above:

  • /classes/FileUploader.php (I don't have the same as you mentionned on line 166) I modified nothing.
  • /js/fileuploader.js (I changed the line 1075 as mentionned)
  • delete the .htaccess file in /js folder (still same)

You can see my PHP info here: http://www.louerbateaumarseille.com/phpinfo.php

 

Do I need to create a new topic ?

Thanks a lot for your help

Link to comment
Share on other sites

  • 1 month later...

I have the same issue with Prestashop 1.5.6.1 and getting the "Undefined" error when I try to upload.  I have tried everything suggested here and nothing seems to work.  I tried using Chrome, Firefox and even IE.  In IE I got the following error info:

 

Webpage error details
 
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
Timestamp: Tue, 15 Apr 2014 01:24:59 UTC
 
Message: Permission denied
Line: 914
Char: 13
Code: 0
 
 
 
That particular line seems to be related to a fix for Opera
 
This is very frustrating.
Link to comment
Share on other sites

I'm have the exact same problem, however, I'm no programmer - and your posts are way out of my league.  However, I'd still appreciate a simple, step by step procedure on how to fix this error.  When I press the "upload an image" button to add a picture for my product...it does nothing.  Completely nothing.  I've added products for months - never a problem until now.  I would so appreciate some assistance...as this is costing our company money.

 

Also, is there a trick to being able to see the posts made by others on here? I can only see replies but cant see the solutions people posted and can find anywhere to click on the i.e "4 Posts" button etc under each persons comments....

Not normally a nufty with computers but cant fiure this one out either :)

Link to comment
Share on other sites

×
×
  • Create New...