Skip to main content
Code Review

Return to Revisions

5 of 5
replaced http://stackoverflow.com/ with https://stackoverflow.com/

There are two ideas mixed together that complicate the code:

  • Manipulating an image.
  • Uploading an image.

Separate the concerns into two different classes (e.g., SimpleImage and SecureImageUpload).

See the SimpleImage class for a reasonably designed class that handles image manipulation. It has methods to resize, scale, load, and save image files of various formats. I'd recommend that you extend the SimpleImage class to include methods that expose the extra functionality you desire.

Encapsulation means that object data is manipulated by exposing methods to other objects. For example:

$image->load( "filename.jpg" );
$image->scale( 100 );
$image->save( "thumbnails/filename.jpg" );

Securely handling image file uploads in PHP is a daunting task to do correctly. See:

Dave Jarvis
  • 1.9k
  • 1
  • 12
  • 29
default

AltStyle によって変換されたページ (->オリジナル) /