Magento - Upload HTTP Error?
Asked Answered
S

8

11

I seem to get an "Upload HTTP Error" whenever I try to upload images in Magento 1.7's admin. I have the entire media folder/files set to 777, .htaccess info is correct, I'm not using password protection, and this happens in any browser.

Any suggestions are greatly appreciated!

Serious answered 25/9, 2013 at 1:14 Comment(1)
It can be also #2234127Scornful
B
16

There are many things that could be causing this issue, but here's a few things you could try:

  • Make sure the /media directory and all subdirectories have your Apache's user's group (usually 'www-data' or 'httpd'):

    sudo chgrp -R www-data /path/to/magento/media
    
  • Make sure the /media directory and all subdirectories have appropriate permissions given to your Apache's user's group:

    sudo chmod -R 775 /path/to/magento/media
    
  • In System->Configuration->General->Web, make sure "Base URL" and "Base Media URL" are correct under both "Secure" and "Unsecure"

    1. In your Magento database, the table core_config_data contains the raw values for your {{secure_base_url}} and {{unsecure_base_url}}

      Make sure these values are correct and have trailing slashes, like http://example.com/

    2. In the system configuration above, make sure those values are correct accounting for the trailing slash in the raw value. This means they should look like {{secure_base_url}}media for example, with no slashes

  • In System->Cache Management, disable caching

  • Take the .htaccess files from a fresh download of your version of Magento (including the .htaccess in your document root, and any .htaccess files in /media and all subdirectories of /media), back up your current .htaccess files, then explicitly copy the fresh .htaccess files to replace them.

    Because .htaccess starts with the '.' character, it will be ignored by certain Linux commands, which can cause people to think they've copied or overwritten a .htaccess file when they actually haven't, so do this carefully.

    Now try again, and if you get the same error, that'll rule out .htaccess.

  • If you're using SSL, try disabling SSL and if you get the same error, that'll rule out SSL

  • Navigate to app/code/local and app/code/community and make note of the namespaces in those directories. Now go to app/etc/modules and edit every *.xml file in that directory matching the namespaces you noted with the following value for the <active> node:

    <?xml version="1.0"?>
    <config>
        <modules>
            <Namespace_*>
                <!-- set this value to "false" -->
                <active>false</active>
                <!-- more nodes here, just leave every
                     node alone except <active> -->
            </Namespace_*>
        </modules>
    <config>
    

    Now try again, and if you get the same error, that'll rule out module conflicts

  • If the images are large enough, you may be restricted by your PHP settings:

    1. Identify your loaded php.ini:

      <?php
      phpinfo(); // Look for "Loaded Configuration File"
      
    2. Edit your php.ini (if you're on Ubuntu it was probably in /etc/php5/apache2/php.ini):

      sudo vi /path/to/php.ini
      
      # Make these three values higher than the filesize of the images you're
      # trying to upload:
      upload_max_filesize = 200M
      post_max_size = 200M
      memory_limit = 200M
      

      Restart your webserver:

      sudo /etc/init.d/apache2 restart
      

If you've gotten this far and nothing has worked, here are some time-intensive things you could do to narrow down what kind of problem it is:

  • Create a fresh install of Magento on the same webserver and test image uploads.

    1. If they still don't work, it's a problem with Apache or PHP configuration (or possibly even version)

    2. If they do work, it was probably a problem with your Magento core files or your Magento configuration or Magento database or Apache virtual host. Take these steps to help determine which:

      1. Create a new database

      2. Delete everything in /path/to/new/magento/var/*

        sudo rm -rf /path/to/new/magento/var/*
        
      3. In your older Magento admin, go to System->Tools->Backups and click Create Backup. Once that's done, go to /path/to/old/magento/var/backup/ and insert your backup into the new database you created:

        mysql -p -u username database_name < backup_file
        
      4. In your new Magento file system, navigate to /path/to/new/magento/app/etc/local.xml and edit it to point to your new database:

        <username>{{db_user}}</username>
        <password>{{db_pass}}</password>
        <dbname>{{db_name}}</dbname>
        
      5. Try image uploads on the fresh Magento install again, and if you get the error, the problem is in your Magento configuration or your Magento database. If you don't get the error, the problem was in your Magento core files or your Apache virtual host.

If you'd like to provide more information, probably the most useful pieces would be a copy of your loaded php.ini, apache2.conf and/or httpd.conf, and copies of your .htaccess files from document root through all subdirectories of /media, with any sensitive information obfuscated of course.

Butters answered 25/9, 2013 at 5:24 Comment(2)
This was the best list of solutions I've seen regarding this problem. In the end, I ended up reinstalling on a new host, which seems to have solved the problem.Serious
"mcrypt" and "gd" PHP extensions missed. Above list of things to check Very Useful, thanks for it. However I've checked it all and didn't get a result on my Magento. Eventually I've found the problem - maybe it will be useful for someone - two PHP extensions needed for Magento to work properly were missing after server migration done some time ago - "mcrypt" and "gd". Probably one of them cause upload "HTTP error". After installing both it works like a charm.Paraglider
O
13

To add to chjohasbrouck's answer, you can also get this error from not having the GD PHP extension enabled.

To install on Ubuntu w/ Apache do:

sudo apt-get install php5-gd

and then restart apache.

Further Ubuntu instructions here: http://www.cyberciti.biz/faq/ubuntu-linux-install-or-add-php-gd-support-to-apache/

Osterman answered 10/3, 2014 at 18:8 Comment(0)
P
9

If you have password-protected your root directory using an .htaccess file, remove this protection and try again.

Inside your .htaccess, look for:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/passwd_file
AuthGroupFile /dev/null
require valid-user

Make sure to re-check your security setting needs, as you might find better ways to protect your site than this one.

Principe answered 27/1, 2014 at 4:15 Comment(2)
Thank you very much. That solved the upload error :)Berfield
It's not very secure just to remove the directory restriction as the website will be available by public then. Better add "Allowed from" entries related to certain IP's if possible.Margotmargrave
L
2

Wrong permission is issue behind this error. If Changing group to apache/www-data user and changing write permission doesnt solve this. Disable .htpasswd authentication if enabled into .httaccess to do this comment these lines

#AuthType Basic
#AuthName "Password Protected Area"
#AuthUserFile .htpasswd path
#Require valid-user
Lashondra answered 10/9, 2014 at 11:12 Comment(0)
N
2

Dealing with the same problem I found that in my case it was an issue with my nginx config.

The default maximum upload size for nginx is 1MB. If you upload larger files you'll see 413 errors in your nginx error log, while Magento will just tell you a non-descriptive "http upload error".

Change or add [client_max_body_size] parameter in nginx.conf, somewhere in the http {} section, like this example where I set the maximum upload size to 200mb:

http {

    client_max_body_size 200m; 

}
Nne answered 11/3, 2015 at 6:55 Comment(1)
Looking at the console log in Chrome, I could see the 413 error, which helped me debug and apply this solution. Nice!Individualism
N
2

I had this problem in Magento 1.7 because the image file name "dutchman's_pipe.jpg" contained an apostrophe. I hope this help's someone else.

Notum answered 30/8, 2016 at 17:36 Comment(0)
C
0

I found another possible reason. In Magento version 1.6.2.0 this occurred because under System --> Web --> Session REMOTE_ADDR and HTTP_USER_AGENT were activated. I switched both again to "no" and this error disappeared (without any other change!)

Cisneros answered 26/6, 2014 at 9:24 Comment(0)
I
0

I experienced the same problem on my Ubuntu 10.04 server. It was caused by this particular setting.

Now I made the following change in this file: /etc/apache2/mods-available/fcgid.conf (you must have root access to modify it):

FcgidMaxRequestLen 1073741824

Almost on the end after the last row of Fcgi commands and before the </IfModule> just add:

<IfModule mod_fcgid.c>
    AddHandler    fcgid-script .fcgi
    FcgidConnectTimeout 60
    FcgidMaxRequestLen 1073741824
</IfModule>
Ideally answered 22/11, 2014 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.