Advertisement
freddy0512

upload images

Jul 9th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. $this->form_validation->set_rules('li_article', 'Artikel', 'trim|required');
  2. $this->form_validation->set_error_delimiters('<font color="red">', '</font>');
  3. if ($this->form_validation->run() == FALSE)
  4. {
  5. //errors input type
  6. $data['penulis'] = $this->penulis_model->getAllPenulis();
  7. $data['gereja'] = $this->gereja_model->getAllPenulis();
  8. $this->template->load('template','user/adminlin/tambah',$data);
  9. }
  10. else
  11. {
  12.  
  13. /setting configuration uploads
  14. $config['upload_path'] = './uploads/lintas';
  15. $config['allowed_types'] = 'gif|jpg|png';
  16. $config['max_size'] = '500';
  17. $config['max_width'] = '1024';
  18. $config['max_height'] = '768';
  19. $this->upload->initialize($config);
  20.  
  21. //check if upload images
  22. if(!$this->upload->do_upload('foto'))
  23. {
  24. //errors shown
  25. }
  26. else
  27. {
  28. $image_info = getimagesize($_FILES["foto"]["tmp_name"]);
  29. $image_width = $image_info[0];
  30. $image_height = $image_info[1];
  31. if (($image_height=='600') and ($image_width=='600'))
  32. {
  33. //eksekusi insert to table
  34. }
  35. else
  36. {
  37. echo "images should match width and height!";
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement