PHP Classes

PHP Upload Picture: Validate and resize an uploaded image file

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (4 months ago) RSS 2.0 feedNot enough user ratingsTotal: 887 All time: 3,977 This week: 40Up
Version License PHP version Categories
upload-picture 1.9BSD License5.3PHP 5, Graphics, Files and Folders, V...


This class can validate and resize an uploaded image file.

It takes an array entry from the $_FILES array for a given uploaded file and checks if it has one of the allowed file name extensions, checks if it as one of the allowed MIME types, and checks if the file size does not exceed the limit size.

Valid picture images may be moved to a given directory with the original name or a given new name.

The class may also rescale the image to fit a given width and height preserving the original picture proportions.

The class may also save the picture in JPEG format with a given compression level.

The class throws exceptions for any validation or processing errors.

Picture of catalin
  Performance   Level  
Name: catalin <contact>
Classes: 6 packages by
Country: Romania Romania
Age: 43
All time rank: 108826 in Romania Romania
Week rank: 298 Up4 in Romania Romania Up


uploadPicture ============= Easy upload for image files. Allow change of file name. Alow change of save path (but this save path must creted before, with correct right). Allow resize and compression. OBS: after resize or compression all files will be saved as jpg/jpeg.

  Files folder image Files  
File Role Description
Accessible without login Plain text file index.php Aux. Example html file for upload
Accessible without login Plain text file Data Short description
Accessible without login Plain text file uploadFile.php Example Example file: how to use
Plain text file UploadPicture.php Class Main class file

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:3,977
This week:40Up