codeigniter l4 file upload & image manipulation & language
TRANSCRIPT
![Page 1: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/1.jpg)
Codeigniter Framework
4. File Upload & Image manipulation & Language
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 2: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/2.jpg)
Agenda
• File upload.
• Image manipulation.
• Language.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 3: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/3.jpg)
File upload
• File Upload class.
• Upload Form.
• Upload controller function.
• Upload class functions.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 4: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/4.jpg)
File upload class
• You can set various preferences,
restricting the type and size of the files.
• Uploading a file involves the following
general process:
An upload form is displayed.
When the form is submitted the file is
validated to make sure it is allowed to
be uploaded based on the preferences
you set.Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 5: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/5.jpg)
Upload form
• File uploads require a multipart form.
form_open_multipart('upload/do_upload');
<input type="file" name="userfile" size="20" />
<input type="submit" value="upload" />
form_close();
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 6: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/6.jpg)
Upload controller function
function do_upload(){
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
echo $this->upload->display_errors();
else echo $this->upload->data();
}Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 7: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/7.jpg)
Upload class functions
• $config array to set your preferences.
• do_upload() Performs the upload based
on the preferences you've set.
• data() returns an array containing all of
the data related to the uploaded file.
• display_errors() retrieves any error
messages if the do_upload()
function returned false.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 8: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/8.jpg)
Live Test
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Let’s Try It
Live!
![Page 9: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/9.jpg)
Image manipulation
• Image class.
• Class initializing.
• Class functions.
• Ex: resize function.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 10: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/10.jpg)
Image class
class lets you perform the following actions:
• Image Resizing.
• Thumbnail Creation.
• Image Cropping.
• Image Rotating
• Image Watermarking.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 11: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/11.jpg)
class Initializing
• Image class is must initialize in your
controller using as following:
• $config : array to set preferences.
$this->load->library('image_lib‘,$config);
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 12: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/12.jpg)
Class functions
$this->image_lib->resize()
$this->image_lib->crop()
$this->image_lib->rotate()
$this->image_lib->watermark()
$this->image_lib->clear()
$this->image_lib->display_errors()
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 13: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/13.jpg)
Ex: resize function
$config['source_image']=‘./upload/mypic.jpg';
$config['new_image']='./thumbnail/newpic.jpg‘;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config[‘hight'] = 75;
$config['width'] = 50;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 14: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/14.jpg)
Live Test
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Let’s Try It
Live!
![Page 15: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/15.jpg)
Language
• Language class.
• Create a language files.
• Loading and Fetching.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
![Page 16: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/16.jpg)
Language class
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• Build web application with multi
language.
• The Language Class provides functions to
retrieve language files and lines of text by
language.
![Page 17: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/17.jpg)
Create language files
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• Language files must be named with
_lang.php as the file extension.
• Your language files must store in
application/language directory.
• assign each line of text to $lang :
$lang['language_key'] = "message to be show";
Language files must be named with _lang.php as the file extension
![Page 18: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/18.jpg)
Loading & Fetching
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
• In order to fetch a line from a particular file
you must load the file first as following:
$this->lang->load('filename', 'language');
• Fetching a line of text :
$this->lang->line(‘language_key’);
Language files must be named with _lang.php as the file extension
![Page 19: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/19.jpg)
Live Test
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Let’s Try It
Live!
![Page 20: CodeIgniter L4 file upload & image manipulation & language](https://reader030.vdocuments.mx/reader030/viewer/2022032421/55a8854c1a28abe9518b480d/html5/thumbnails/20.jpg)
THANK YOU
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Questions?