Image upload problems in PHP

I recently designed several web-based software applications  using PHP & MySQL.  Some of the applications allow the user to upload photographs to the web server.  However, it seems many times when I install one of these apps on a new server, I have trouble with the image upload feature.  After several episodes of head-scratching, I’m posting everything I know about the subject here.  Hopefully, it will server as a reminder to me and some assistance to others.

Most of the Linux servers I maintain are running Ubuntu 8.04, so the specific file locations will be geared toward that distribution.

  1. Make sure the php5-gd package is installed. That’s pretty basic but can be overlooked(I’m living proof of that). In Ubuntu 8.04 the command to install the appropriate package is:
    sudo apt-get install php5-gd
  2. In php.ini (usually in /etc/php5/apache2 or somewhere close), check the following values:
    memory_limit needs to be of sufficient size.
    post_max_size needs to be of sufficient size.
    file_uploads needs to be on
    upload_max_filesize needs to be of sufficient size
  3. Make sure the default system temp directory (usually /tmp) is writable by everybody.  This is usually the case by default, but I had this trouble on some physical servers that I had converted to OpenVZ containers.

Good luck! 🙂

Goodbye to, hello to

eldon-landry-evAbout a week ago I pulled the plug on my website.  I started the site a few years ago with big dreams of it becoming the place to go for news on alternative energy and electric cars.  Unfortuately, one guy can only do so much in a 24-hour day.  So EVNow is one hobby that had to go.

On the bright side, is back on its feet.  Last spring I had replaced the home page of the site with a message about going out of business.  At the time I had taken a position with the Fulton County Government.  I am still happily employed there, but I have begun to do some web programming on the side.  No, I am not doing repair and networking, so don’t rush to the phone to call me concerning your virus infested home computer.

Finally, Google Chrome on my Ubuntu Desktop

Yesterday I stumbled across an article on how to install the beta version of Google Chrome on my Ubuntu 9.10 desktop. The article mentioned using the command line, but I found just downloading the file, double-clicking to open it, and then clicking “Install” did the job just fine.  Nice!

ProxMox VE – The best virtualization software you haven’t heard of

Before you plunk down serious cash on an enterprise virtualization solution, check out the free, open-source ProxMox VE.  It is based on two mature open-source virtualization products, namely OpenVZ and KVM.  I maintain two physical ProxMox VE servers running a total of eight virtual machine “guests”, including Ubuntu 8.04, Ubuntu 9.04, Windows 2003, and CentOS.  So far, the expirience has been nothing but positive.

To download ProxMox VE, head over to the developers website at and find ProxMox VE on their product page.  Or just go straight to to get right into the good stuff.

There’s also a good review of ProxMox over at

The best open-source time wasters

I cringe when I hear of somebody buying a computer game.  It’s like paying for the privilege of wasting time.  I can’t be too critical, however; because a few years back I was an avid game player myself.  At the height of my time-wasting addiction, I played Age of Empires II for as long as ten hours straight.

Screenshot of GlestFor those of you who are still into gaming, I can recommend a couple of very nice commercial-quality games available for free.  They still waste your time, but not your money.

The first is Glest.  It is a real-time strategy game with game play similar to the Age of Empires series.  Like most modern RTS games, it uses a 3D rendering engine so you are free to change your point-of-view by rotating and zooming the display.  The more recent versions have added the ability to play with others over the Internet.  Nice!

Screenshot of Battle for WesnothAnother good one is Battle for Wesnoth.  This is a turn-based strategy game and there is a bit of a learning curve.  If your experience is like mine, the effort will pay off with a LOT of wasted time and possibly a stubborn addition to the game.  Like Glest, you can play against the computer or other humans.  Since it is turn-based, Wesnoth can even be played like a board game by several time-wasting humans huddled around a single PC.

Exporting email addresses from Microsoft Exchange

It seems like mail server software from the largest software company on earth would include an easy way to export email addresses for printing or use by other programs.  Unless I’m missing something, that is not the case.  It can be done, but it takes some work.  Here is how I accomplish it:

  1. From within Outlook, click on File > Folder > New Folder
  2. Give it a name, such as BernardoIsCool
  3. Pull down the list of options beside “Folder Contains:” and select “Contact Items”
  4. Select Contacts as the location to place the folder, and click OK
  5. Click Tools > Address Book
  6. From within the address book, click Tools > Options
  7. Under “Keep personal addresses in:” choose the folder you created in Step 2
  8. Click OK
  9. Select all of the addresses in the address book.  Because neither CTRL+A nor the edit menu will help you with this (What is up with that, Billy?), click on the topmost address and then use SHIFT+PAGE DOWN to select the rest.
  10. Right-click on one of the selected addresses and click “Add to contacts”
  11. Close the address book, and go to your Outlook Contacts. Select the newly created folder and you should see everybody in the global address book.
  12. Finally, use File > Import and Export tool to get the list of addresses into a CSV (comma-separated text file).  You can then use Calc or Excel to get rid of the extra columns.

Say “Hi” to Google Chrome

A few weeks ago, Google took the wraps off of a new web browser called “Chrome“.  The browser enters into competition against a handful of entrenched foes, mostly notably Microsoft Internet Explorer and Mozilla Firefox.  I took Google Chrome for a spin over the past few days and like what I see.  The user interface is simpler than either IE or Firefox, and it appears to be  the fastest of the three browsers as well.

Chrome is supposedly optimized to run web applications such as those provided by Google.   Some even say it will eventually replace Windows as fewer applications are installed on computers and more of them hosted online.

What do you think?  Is this a possibility?

Solved: Web server clock problem

As I previously mentioned, my Ubuntu web server seems to have a clock problem, presumably because it is running within VMWare.  I found a simple way to keep the clock relatively accurate.  This is probably not the best solution, but it works for me.

I created the following script within the directory /etc/cron.daily

ntpdate > /dev/null
exit 0

Then I made it executable by issuing this command:

chmod +x   (change to the name you gave to the script)

This syncronizes the system clock with an Internet time server every day.  By the end of the day the time is off a minute or two, but accurate enough for my use.

Timekeeping woes on my web server

As happy as I am with my Ubuntu-within-VMware-within-Ubuntu web server, it seems to have a problem with keeping correct time.  For example, I am writing this post on June 6, 2008 at 10:19 pm.  No doubt that time will not match the date and time stamp displayed by WordPress.

In some ways it isn’t a big problem.   Aside from confusing my eGroupware calendar, the only place it shows up is on my blog and evnow posts.  Where the problem could become more serious is if my blog posts begin to display timestamps that are during business hours of my place of employment.  So, to set the record straight, I never write on my web sites during work hours.  Now that I’m not trying to run a computer service business, I have enough time to write when I’m not at work.

It appears that the VMware web site contains an article about the problem but I’ve been too lazy to implement it. It seems part of the solution is to install VMware tools on the guest OS, and my first attempt to do so failed.   Oh well..   I’ll get around to it eventually.

So anti-virus software really IS a joke!

In the past two or three years, I’ve mentioned more than once that anti-virus software is a joke.  That was probably a slight exaggeration, but the fact remains that anti-virus software does a horrible job protecting a computer from malicious software. Apparently I’m not completely crazy. John Stewart, the chief security officer at Cisco, says anti-virus software purchases are “completely wasted money“.  Although I would not go that far, there is some truth to what he says.

When I was still doing work for residential customers, about three out of four service calls were to clean viruses.  Most of those whose computers fell prey had already installed respected, up-to-date anti-virus software.   Anti-virus vendors simply cannot keep up with the bad guys writing bad software.  In my opinion, the only real anti-virus is some caution employed by the person using the computer.

The interesting part of John Stewart’s opinion is the idea of using a software “whitelist”, where only those programs you’ve explicitly allowed will be able to run on your network.  It’s a new concept for me, but it seems like a workable one at least for the enterprise. Most larger businesses have a documented inventory of software in use on their network, so making a whitelist wouldn’t be too difficult.  The only question is how updates would be handled.  It seems you would have to modify the whitelist every time an update for Adobe Acrobat or Flash Player became available.  Maybe the best way would be to make a vendor whitelist.  Hmm….