SafelyUpload Class : Upload your pictures safely

To simplify my images uploads, I coded a small PHP class which allows you to upload pictures by recreating them using GD library, this manip is more safer than using move_uploaded_file.

WORK ONLY WITH IMAGES FORMATS

See the demo

Example code :

require_once("SafelyUpload.php"); // Require SafelyUpload PHP class
$upload	=	new SafelyUpload($_FILES['image'],"uploads",75);
$upload->resize(400);	// Optional !! Resize to width = 600  if width > height || Height = 600 if height > width
if( $upload->upload() ){
echo"Photo uploaded successfully<br /><img src=\"".$upload->new_name."\" />";
}
else{
echo $upload->error;
}

Read the rest of this entry »