Yet Another WordPress Flash Uploader Problem (with solution!)

This was a new one for me. Every time I tried to upload a photo to a WordPress site, I received a very informative “HTTP Error” message while the upload progress bar read “Crunching…”. Thanks in part to the stunningly generic error message, it took a while to figure out exactly what was going on.  The problem, it turns out, was HTTP authentication; I had enabled Apache’s basic HTTP login for the site, but being a plugin, Adobe Flash was not similarly authenticated.  So, trying to use the Flash-based image uploader kept silently failing because it couldn’t authenticate with the server.  The fix is simple: just tell Apache not to use authentication for the script that handles Flash-based uploads.  You can do this by modifying the .htaccess file in the root of your WordPress directory like so:

<FilesMatch "(async-upload.php)$">
    Satisfy Any
    Order allow,deny
    Allow from all
    Deny from none
</FilesMatch>

PHP ZIP Extension for MAMP

Do you use MAMP as a web development testing environment on your Mac?

Do you need the PHP ZIP extension for dealing with archive files?

Are you running Mac OS X 10.6 Snow Leopard?

I do, and found making these tools play nice together to be far harder than it should have.  If you need to fix a similar setup, here are the steps that finally worked for me (on Mac OS X 10.6.4 with MAMP 1.9):

  1. Install XCode if you don’t already have it (we’re going to be doing a bit of compiling).
  2. Download the MAMP source code components (available towards the bottom of the page).
  3. When the MAMP source code package opens, go into the MAMP_src folder and double-click the php-5.3.2.tar.gz file (if you are using a different version of PHP, replace 5.3.2 with your actual version number).
  4. You should now have a php-5.3.2 folder in your Downloads folder.  Open up Terminal and cd to ~/Downloads/php-5.3.2.:
    cd ~/Downloads/php-5.3.2/
  5. Install the pcre.h header file (we need it to compile the extension):
    sudo cp ext/pcre/pcrelib/pcre.h /usr/include/php/ext/pcre/
  6. Configure PHP for i386 architecture:
    CFLAGS="-arch i386" ./configure
  7. Configure the ZIP extension for i386 architecture:
    cd ext/zip; CFLAGS="-arch i386" ./configure
  8. Build the extension:
    make
  9. Install the extension:
    cp modules/zip.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/
  10. Enable the extension by opening /Applications/MAMP/conf/php5.3/php.ini and appending the following line:
    extension=zip.so
  11. Remove the pcre.h header file we installed earlier, we don’t need it anymore.
  12. Restart MAMP.  If everything worked properly, you’ll be able to goto http://localhost/MAMP, click on phpInfo, and see zip in the list of enabled extensions.