Welcome Guest, Not a member yet? Register   Sign In
IMage Upload & Resize
#3

[eluser]the_unforgiven[/eluser]
Yes looked over the manual, and think I have sorted it, but here's the code anyhow

[code]
function do_upload()
{
$config['upload_path'] = '/images/staff/';
$config['allowed_types'] = 'gif|jpg|png|JPG|jpeg';
$config['max_size'] = '1000';
$config['max_width'] = '180';
$config['max_height'] = '140';

$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());

$this->load->view('addteam', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());

$this->load->view('saveteam', $data);
}
}

function saveteam()
{
if (!$this->tank_auth->is_logged_in() ) {
redirect('/auth/login/');
} else {
$this->load->library('session'); //for getting the session value for last page, and redirecting to the right listing page
// Get ID from form
$id = $this->input->post('id');

// Validation rules
$vrules['id'] = 'required';
$vrules['position'] = '';
$vrules['name'] = '';
$vrules['image'] = '';
$vrules['profile'] = '';
$this->validation->set_rules($vrules);

// Validation fields
$vfields['id'] = 'ID';
$vfields['position'] = 'Position';
$vfields['name'] = 'Name';
$vfields['image'] = 'Image';
$vfields['profile'] = 'Profile';
$this->validation->set_fields($vfields);

// Set the error delims to a nice styled red hint under the fields
$this->validation->set_error_delimiters('<p class="hint error"><span>', '</span></p>');


if ($this->validation->run() == FALSE){
// Validation failed
if($id != "X"){
return $this->EditTeam($id, $_POST);
} else {
return $this->AddTeam($_POST);
}
} else {

// Validation succeeded!
// Create array


Messages In This Thread
IMage Upload & Resize - by El Forum - 06-30-2011, 04:03 AM
IMage Upload & Resize - by El Forum - 06-30-2011, 06:06 AM
IMage Upload & Resize - by El Forum - 06-30-2011, 06:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB