Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Upload HTTP Error?

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!

like image 651
Midnightly Coder Avatar asked Sep 25 '13 01:09

Midnightly Coder


4 Answers

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/

like image 50
pantsburgh Avatar answered Nov 12 '22 13:11

pantsburgh


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.

like image 36
gardener Avatar answered Oct 21 '22 05:10

gardener


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.

like image 16
Adelmar Avatar answered Nov 12 '22 15:11

Adelmar


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.

like image 9
Meetai.com Avatar answered Nov 12 '22 14:11

Meetai.com