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! 🙂

39 thoughts on “Image upload problems in PHP

  1. Pingback: Oliver

  2. Pingback: Jeff

  3. Pingback: todd

  4. Pingback: Henry

  5. Pingback: rex

  6. Pingback: Carlton

  7. Pingback: curtis

  8. Pingback: Mario

  9. Pingback: brett

  10. Pingback: keith

  11. Pingback: howard

  12. Pingback: Matt

  13. Pingback: jeff

  14. Pingback: Ronald

  15. Pingback: harvey

  16. Pingback: lance

  17. Pingback: Marcus

  18. Pingback: arnold

  19. Pingback: Jacob

  20. Pingback: lewis

  21. Pingback: felix

  22. Pingback: Donald

  23. Pingback: reginald

  24. Pingback: walter

  25. Pingback: joel

  26. Pingback: Sidney

  27. Pingback: Shane

  28. Pingback: Douglas

  29. Pingback: Lonnie

  30. Pingback: sean

  31. Pingback: Ronald

  32. Pingback: Christopher

  33. Pingback: otis

  34. Pingback: victor

  35. Pingback: Daniel

  36. Pingback: Dennis

  37. Pingback: kent

  38. Pingback: Joey

  39. Pingback: morris

Comments are closed.