Hi all,
I'm using the following code (taken from PHP Solutions by David Powers)
//Image Upload
//Set the maximum upload size in bytes
$max = 250000;
if (isset($_POST['insert'])) {
//define the path to upload folder
$destination = '../images/';
require_once('../Ps2/Upload.php');
try {
$upload = new Ps2_Upload($destination);
$upload->move();
$result = $upload->getMessages();
} catch (Exception $e) {
echo $e->getMessage();
}
}
//End Image Upload - start processing the rest of the form
Upload.php
<?php
class Ps2_Upload {
protected $_uploaded = array();
protected $_destination;
protected $_max = 250000;
protected $_messages = array();
protected $_permitted = array('image/jpg',);
protected $_renamed = false;
public function __construct($path) {
if (!is_dir($path) || !is_writable($path)) {
throw new Exception("$path must be a valid, writable directory.");
}
$this->_destination = $path;
$this->_uploaded = $_FILES;
}
public function move() {
$field = current($this->_uploaded);
$success = move_uploaded_file($field['tmp_name'], $this->_destination . $field['name']);
if ($success) {
$this->_messages[] = $field['name'] . ' uploaded successfully';
} else {
$this->_messages[] = 'Could not upload ' . $field['name'];
}
}
public function getMessages() {
return $this->_messages;
}
}
I'd now llike to know how to resize the image on upload to make it 400px in height?
Any help would be appreciated.
Tom