Jump to content

Image Upload Issue


Recommended Posts

I'm new to Prestashop, which looks fantastic BTW, but I'm having problems uploading images. I've just done a fresh install of Prestashop onto my hosting providers server, ensuring that I set all directories to writable where required. My install passed all checks for writable directories, and I have no issues accessing and navigating the shop or the back office.

Whenever I try to add an image to a product, I get an error: "an error occurred while copying image". I've tried JPG, PNG and GIFs, and all my test files are under 30Kb.

My hosting meets all system requirements (PHP5, MySQL5, etc). Safe Mode is Off, so it shouldn't be that. Can anyone help? I'm not even sure where to start troubleshooting this?

Link to comment
Share on other sites

I was looking at this more over the weekend, and discovered that when I try to upload an image, something pretty strange seems to be happening. In the img folder there's a tmp folder. Before I try to upload an image, it's empty aside from an index.php file. But after I have a failed image upload, there are 4 images named product-mini-X.jpg in the folder - each one a tiny thumbnail of an existing product in the store. None of them, I might add, are the image I'm trying to upload.

This may be part of some standard thumbnail creation stuff, but I would have thought that products that already exist wouldn't need new thumbs created.

I'm using the latest version of PrestaShop, clean installed to my hosting server, with no changes except that I've added one new product and I'm trying to get image uploads to work.

Link to comment
Share on other sites

I've been struggling with this image upload issue for a while and have finally found a solution to my problem. I thought I'd detail what I did in case it helps anyone else.

For me, the issue was related to the fact that my hosting provider uses open_basedir restrictions. This allows them to limit which directories my PHP scripts have access to read and write to. Like a lot of hosting providers, they host multiple sites on a single box, so limit what your scripts have access to so you don't have the ability to traverse into another persons directories.

Whenever an image was uploaded, it went into a temporary upload directory that Prestashop did not have the rights to operate in (i.e. was not included in the open_basedir allowed directories). So while the image did get uploaded to the server, Prestashop was unable to then move the file into its image directories and operate on it as normal.

The solution for me was to get my hosting provider to change the PHP temp_upload_dir value to a directory that was inside of those that the open_basedir restrictions allowed me to access. As soon as that change was made, my images upload perfectly, first time!

You can check to see if you have open_basedir restrictions in place by checking your phpinfo. If you have a value in open_basedir (rather than null) then there is a good chance you have those restrictions in place, and they may be affecting your ability to upload images. You may be able to change your temp_upload_dir in your php.ini or .htaccess file, depending on whether or not your host allows that, otherwise you may have to call them and get them to make the change for you.

This may not be the solution for everyone, but it solved it for me, so hopefully it helps someone.

Lastly a huge thanks to amwdesign, who generously helped me diagnose the problem from the other side of the world.

Link to comment
Share on other sites

well, mega huge thx for solving this issue:-)
but i´d like to ask you about how should looks like record in php.ini or rather in .htaccess.
my phpinfo information is:

open_basedir    .:/httpd/html/sh_artifactseu
upload_tmp_dir    /httpd/html/sh_artifactseu/tmp


thx very much for any reply.

updated:
I find out that my tmp directory was deleted thats why i had upload issue problem.
Now is everythig working.

Link to comment
Share on other sites

  • 2 months later...
I've been struggling with this image upload issue for a while and have finally found a solution to my problem. I thought I'd detail what I did in case it helps anyone else.

For me, the issue was related to the fact that my hosting provider uses open_basedir restrictions. This allows them to limit which directories my PHP scripts have access to read and write to. Like a lot of hosting providers, they host multiple sites on a single box, so limit what your scripts have access to so you don't have the ability to traverse into another persons directories.

Whenever an image was uploaded, it went into a temporary upload directory that Prestashop did not have the rights to operate in (i.e. was not included in the open_basedir allowed directories). So while the image did get uploaded to the server, Prestashop was unable to then move the file into its image directories and operate on it as normal.

The solution for me was to get my hosting provider to change the PHP temp_upload_dir value to a directory that was inside of those that the open_basedir restrictions allowed me to access. As soon as that change was made, my images upload perfectly, first time!

You can check to see if you have open_basedir restrictions in place by checking your phpinfo. If you have a value in open_basedir (rather than null) then there is a good chance you have those restrictions in place, and they may be affecting your ability to upload images. You may be able to change your temp_upload_dir in your php.ini or .htaccess file, depending on whether or not your host allows that, otherwise you may have to call them and get them to make the change for you.

This may not be the solution for everyone, but it solved it for me, so hopefully it helps someone.

Lastly a huge thanks to amwdesign, who generously helped me diagnose the problem from the other side of the world.



I think I have the same problem. I can't upload images to Prestashop. Installation was ok, all requirements checked green (ok). I checked on my hosting via phpinfo, that upload_tmp_dir is set to be outside of open_basedir. I asked my provider to change it, but he replied that from system reasons, they do not change upload_tmp_dir and that correct way of uploading file is to use move_uploaded_file function. I'am not very into PHP, can you please help?
Link to comment
Share on other sites

  • 2 months later...

sorry i forgot to mention that sometimes you have to rename it a couple of times, I copy all of my images into a new folder named imagesUpload but always try to rename them somthing relevant so they renmain in numerical order.

hope this helps

Link to comment
Share on other sites

  • 3 weeks later...

I am using 1and1 and I can modify the php.ini file, and see the changes in phpinfo(). Following above, I made changes to open_basedir and upload_tmp_dir so that they are inside my prestashop directory. When I import a product (using an ID of 405 for this example) I don't get any errors during the import, but there are no images created for the product. The product thinks the images are created because it loads the links pointing to img/p/405-1.jpg and img/p/405-2.jpg, but there are no images in that folder. Any ideas? Thanks in advance.

Link to comment
Share on other sites

  • 1 month later...

has anyone got an update to this issue an error occurred while uploading image

i am using a 1and1 server dedicated which is a plesk 9.01 running centos

i am unable to upload any images, i have setup prestashop on a 1and1 hosting accoutn with no problem as there hosting accounts seem to have the directive of open_basedir set to none, however on plesk server they have it set to

open_basedir /var/www/vhosts/virtualdomainname/httpdocs:/tmp

i have tried to create the directory :tmp in shell still no joy i have tried editing the httpd.include and restarted apache

still no joy, do the developers or anyone have a fix ?


Regards

Link to comment
Share on other sites

  • 1 year later...

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...