IMage Upload & Resize |
[eluser]the_unforgiven[/eluser]
What is the best way to upload an image and resize an image in CI, still learning Ci and getting to grips with it nicely but the controller, model i have created to upload an image doesn't work and not sure why. Just wondered if someon can point me in the right direction of where to go with this.
[eluser]Xclamation Design[/eluser]
Have you looked at the File Uploader class (http://ellislab.com/codeigniter/user-gui...ading.html)? For resizing images, you might want to check out the following link: http://www.white-hat-web-design.co.uk/ar...sizing.php It might also help us to help you if you can provide some of your code so that we can see where you have got to...
[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 |
Welcome Guest, Not a member yet? Register Sign In |