SlideShare a Scribd company logo
Codeigniter Framework
4. File Upload & Image manipulation & Language
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Agenda
• File upload.
• Image manipulation.
• Language.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
File upload
• File Upload class.
• Upload Form.
• Upload controller function.
• Upload class functions.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
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
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
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
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
Live Test
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Let’s Try It
Live!
Image manipulation
• Image class.
• Class initializing.
• Class functions.
• Ex: resize function.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
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
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
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
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
Live Test
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Let’s Try It
Live!
Language
• Language class.
• Create a language files.
• Loading and Fetching.
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
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.
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
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
Live Test
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Let’s Try It
Live!
THANK YOU
Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
Questions?

More Related Content

What's hot

2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator
2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator
2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator
norm2782
 

What's hot (18)

Working with databases
Working with databasesWorking with databases
Working with databases
 
CodeIgniter L1 introduction to CodeIgniter framework
CodeIgniter L1 introduction to CodeIgniter frameworkCodeIgniter L1 introduction to CodeIgniter framework
CodeIgniter L1 introduction to CodeIgniter framework
 
XSLT
XSLTXSLT
XSLT
 
MS SQL Database basic
MS SQL Database basicMS SQL Database basic
MS SQL Database basic
 
2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator
2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator
2009-08-28 PHP Benelux BBQ: Advanced Usage Of Zend Paginator
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
Victoria wordpress
Victoria wordpressVictoria wordpress
Victoria wordpress
 
Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子
 
Python Magic Methods: a practical example
Python Magic Methods: a practical examplePython Magic Methods: a practical example
Python Magic Methods: a practical example
 
5. Php MongoDB vederea unui singur document
5. Php MongoDB vederea unui singur document5. Php MongoDB vederea unui singur document
5. Php MongoDB vederea unui singur document
 
7. Php MongoDB editarea unui document
7. Php MongoDB editarea unui document7. Php MongoDB editarea unui document
7. Php MongoDB editarea unui document
 
13. CodeIgniter vederea inregistrarilor3
13. CodeIgniter vederea inregistrarilor313. CodeIgniter vederea inregistrarilor3
13. CodeIgniter vederea inregistrarilor3
 
NEMROD : Symfony2 components to work with native RDF
NEMROD : Symfony2 components to work with native RDFNEMROD : Symfony2 components to work with native RDF
NEMROD : Symfony2 components to work with native RDF
 
Php workshop L04 database
Php workshop L04 databasePhp workshop L04 database
Php workshop L04 database
 
Python magicmethods
Python magicmethodsPython magicmethods
Python magicmethods
 
Php workshop L03 superglobals
Php workshop L03 superglobalsPhp workshop L03 superglobals
Php workshop L03 superglobals
 
Mongo - an intermediate introduction
Mongo - an intermediate introductionMongo - an intermediate introduction
Mongo - an intermediate introduction
 
Java script
Java scriptJava script
Java script
 

Similar to CodeIgniter L4 file upload & image manipulation & language

Managing themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arraysManaging themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arrays
Chris Olbekson
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 

Similar to CodeIgniter L4 file upload & image manipulation & language (20)

Image manipulation in WordPress 3.5
Image manipulation in WordPress 3.5Image manipulation in WordPress 3.5
Image manipulation in WordPress 3.5
 
Web application, cookies and sessions
Web application, cookies and sessionsWeb application, cookies and sessions
Web application, cookies and sessions
 
Real World Seaside Applications
Real World Seaside ApplicationsReal World Seaside Applications
Real World Seaside Applications
 
Usecase examples of Packer
Usecase examples of Packer Usecase examples of Packer
Usecase examples of Packer
 
Managing themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arraysManaging themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arrays
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28th
 
About Data::ObjectDriver
About Data::ObjectDriverAbout Data::ObjectDriver
About Data::ObjectDriver
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
DBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たちDBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たち
 
File Upload 2015
File Upload 2015File Upload 2015
File Upload 2015
 
Drag and drop file upload with Dropzone in CodeIgniter
Drag and drop file upload with Dropzone in CodeIgniterDrag and drop file upload with Dropzone in CodeIgniter
Drag and drop file upload with Dropzone in CodeIgniter
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) Roundup
 
Deploy like a pro!
Deploy like a pro!Deploy like a pro!
Deploy like a pro!
 
So I Wrote a Manifest
So I Wrote a ManifestSo I Wrote a Manifest
So I Wrote a Manifest
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
Drupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and FlickrDrupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and Flickr
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Expert guide for PHP
Expert guide for PHPExpert guide for PHP
Expert guide for PHP
 

More from Mohammad Tahsin Alshalabi

More from Mohammad Tahsin Alshalabi (11)

NUMA optimized Parallel Breadth first Search on Multicore Single node System
NUMA optimized Parallel Breadth first Search on Multicore Single node SystemNUMA optimized Parallel Breadth first Search on Multicore Single node System
NUMA optimized Parallel Breadth first Search on Multicore Single node System
 
Learning Management System in Damascus University-Information Technology Engi...
Learning Management System in Damascus University-Information Technology Engi...Learning Management System in Damascus University-Information Technology Engi...
Learning Management System in Damascus University-Information Technology Engi...
 
Learning management system in information technology engineering faculty
Learning management system in  information technology engineering facultyLearning management system in  information technology engineering faculty
Learning management system in information technology engineering faculty
 
Moodle documentation
Moodle documentationMoodle documentation
Moodle documentation
 
Moodle plugins programing manual
Moodle plugins programing manualMoodle plugins programing manual
Moodle plugins programing manual
 
Comparison between web and mobile application requirements
Comparison between web and mobile application requirementsComparison between web and mobile application requirements
Comparison between web and mobile application requirements
 
Introduction to web services
Introduction to web servicesIntroduction to web services
Introduction to web services
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Php workshop L02 php basics
Php workshop L02 php basicsPhp workshop L02 php basics
Php workshop L02 php basics
 
Php workshop L01 CSS
Php workshop L01 CSSPhp workshop L01 CSS
Php workshop L01 CSS
 
Php workshop L0 Introduction
Php workshop L0 IntroductionPhp workshop L0 Introduction
Php workshop L0 Introduction
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 

CodeIgniter L4 file upload & image manipulation & language

  • 1. Codeigniter Framework 4. File Upload & Image manipulation & Language Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
  • 2. Agenda • File upload. • Image manipulation. • Language. Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
  • 3. File upload • File Upload class. • Upload Form. • Upload controller function. • Upload class functions. Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. Live Test Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi Let’s Try It Live!
  • 9. Image manipulation • Image class. • Class initializing. • Class functions. • Ex: resize function. Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
  • 10. 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
  • 11. 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
  • 13. 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
  • 14. Live Test Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi Let’s Try It Live!
  • 15. Language • Language class. • Create a language files. • Loading and Fetching. Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi
  • 16. 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.
  • 17. 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
  • 18. 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
  • 19. Live Test Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi Let’s Try It Live!
  • 20. THANK YOU Mhd Opada Al-Bosh & Mhd Tahsin Al-Shalabi Questions?