Pure PHP Upload Tutorials - Restrict image width

Restricting image width and height

In this tutorial we will explain how to set minimum and maximum width and height for the uploaded images.

There are two types of image size checking:


How to do it

To make the file upload with restricted image size, you need to:

  1. Start with basic upload page
    Start with an upload page where you have Pure PHP Upload on it. If you haven't done it yet, go through the Simple file upload tutorial.

  2. Open the Pure PHP Upload dialog
    Select the Pure PHP Upload dialog by opening the Server Behaviors Panel. Select DMXzone - Pure PHP Upload.

    Make sure you've selected Images Only for your allowed extensions.


  3. Select the Allowed Image Size
    When you need to restrict the size of the uploaded images, you need to fill in the minimum and/or maximum width and height on the Advanced tab. If you leave one of those values empty it means it is unlimited. The sizes are in pixels.
  4. In our example, we've chosen to limit the image size to min 50x50 and max 200x200 pixels.

  5. Save and done
    Save your page then, upload it to your server, and you are done! Go to your website and test it - you should be able to upload images only that are not bigger then 200x200 pixels and minimum 50x50 pixels.