SlideShare a Scribd company logo
1 of 14
File Management Basics
Overview
Objective

Learn how to create, copy and delete files within a file
system using PHP and ProdigyView.

Requirements

 Access read/write access to various locations in a file
  system

Estimated Time

5 Minutes
Follow Along With Code Example
 1. Download a copy of the example code at
   www.prodigyview.com/source.

 2. Install the system in an environment you feel
   comfortable testing in.

 3. Proceed to examples/util/FileManagement1.php
What is File Management
File management is the process of reading and writing a
file.

If you have performed reading and writing files in
PHP, you may have come across minor frustration if
fread() and fwrite() are being used. You may also have
come across problems with encoding issues or questions
on how to copy entire directories.

ProdigyView takes care of those difficulties for you.
File Locations
Let’s begin this example with creating the directories the
file will be placed in. If you remember the PV_FILE
defines, it sets the location in your file system to place
files.
Writing A File
Writing a file is accomplished with this method:




Passing the variables to this function break down like this.
 $file: The location of the file to write
 $content: The contents to put in the file
 $mode : The mode in writing the file. The default is ‘w’ which
   means write only. If you pass ‘a’, that will append to the file.
 $encoding: By default, no encoding is added to a file but you
   can always add one.
Write a File Code
 With our previous variables set up, lets write information to a
 file.



1. File Location      2. Content to write to file    3. Append content to file




                                                    4. Set the encoding
Reading A File
Reading a file has similar options of writing a file. To read
a file, this function is used:



  $file: The location of the file to read
  $mode: The mode to use when reading the file. The
   same mode options are used that are used in fopen()
   function can be used here.

  $encoding: Default is no encoding, but an encoding
   can be used for the file being returned.
Reading File Example
  Now that you have the functions for writing and reading a
  file, lets put our code to use.

`. Read the file from a location                    2. Set the mode for reading a file




                        3. Set the encoding for the file
New File Only!
Now that we have basics for writing and reading a file, lets
implement some file protection. Using the function
writeNewFile() takes in the exact same parameters as
writeFile, except it checks if the file exist first.


 Will write a file only if it does not exist
Write File Only If It Exist
The opposite of of writeNewFile() is to rewriteNewFile().
This function will only write to a file if it already exist.


1. Write to file only if it exist




                                    2. Read the file
Directories
 One of the things ProdigyView tries to make easier to
 manage is directories. ProdigyView provides the ability to
 copy entire directories and the ability to delete directories
 will relative ease.


1. Set directory to copy                     2. Set location to copy directory




                    3. Delete an entire directory
Review
1. Write a file with PVFileManager::writeFile() method.
  1. PVFileManager::writeNewFile() will only write a file if it
     DOES NOT already exist.
  2. PVFileManager::rewriteNewFile() will only write a file if
     it DOES exist

2. Read a file using PVFileManager::readFile() method.
3. Copy directories using
   PVFileManager::copyDirectory() method.
4. Delete A directory by using
   PVFileManager::deleteDirectory() method.
API Reference
For a better understanding of file management in
ProdigyView, visit the api by clicking on the link below.

PVFileManager




                 More Tutorials
For more tutorials, please visit:

http://www.prodigyview.com/tutorials


                       www.prodigyview.com

More Related Content

More from ProdigyView

Video Content Management
Video Content ManagementVideo Content Management
Video Content ManagementProdigyView
 
Audio Content Management
Audio Content ManagementAudio Content Management
Audio Content ManagementProdigyView
 
File Content Management
File Content ManagementFile Content Management
File Content ManagementProdigyView
 
Email Configuration
Email ConfigurationEmail Configuration
Email ConfigurationProdigyView
 
HTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialHTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialProdigyView
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms TutorialProdigyView
 
Html Tags Tutorial
Html Tags TutorialHtml Tags Tutorial
Html Tags TutorialProdigyView
 
Video Conversion PHP
Video Conversion PHPVideo Conversion PHP
Video Conversion PHPProdigyView
 
Sending Email Basics PHP
Sending Email Basics PHPSending Email Basics PHP
Sending Email Basics PHPProdigyView
 
Tools ProdigyView
Tools ProdigyViewTools ProdigyView
Tools ProdigyViewProdigyView
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHPProdigyView
 
Basic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPBasic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPProdigyView
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web CacheProdigyView
 
Javascript And CSS Libraries
Javascript And CSS LibrariesJavascript And CSS Libraries
Javascript And CSS LibrariesProdigyView
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements TutorialProdigyView
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design PatternProdigyView
 
Intercepting Filters Design Pattern
Intercepting Filters Design PatternIntercepting Filters Design Pattern
Intercepting Filters Design PatternProdigyView
 
Creating Dynamic Objects PHP
Creating Dynamic Objects PHPCreating Dynamic Objects PHP
Creating Dynamic Objects PHPProdigyView
 

More from ProdigyView (20)

Video Content Management
Video Content ManagementVideo Content Management
Video Content Management
 
Audio Content Management
Audio Content ManagementAudio Content Management
Audio Content Management
 
File Content Management
File Content ManagementFile Content Management
File Content Management
 
Email Configuration
Email ConfigurationEmail Configuration
Email Configuration
 
HTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialHTML5 Tags and Elements Tutorial
HTML5 Tags and Elements Tutorial
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms Tutorial
 
Html Tags Tutorial
Html Tags TutorialHtml Tags Tutorial
Html Tags Tutorial
 
Video Conversion PHP
Video Conversion PHPVideo Conversion PHP
Video Conversion PHP
 
Sending Email Basics PHP
Sending Email Basics PHPSending Email Basics PHP
Sending Email Basics PHP
 
Tools ProdigyView
Tools ProdigyViewTools ProdigyView
Tools ProdigyView
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHP
 
Basic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPBasic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHP
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
 
Javascript And CSS Libraries
Javascript And CSS LibrariesJavascript And CSS Libraries
Javascript And CSS Libraries
 
PHP Libraries
PHP LibrariesPHP Libraries
PHP Libraries
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements Tutorial
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Intercepting Filters Design Pattern
Intercepting Filters Design PatternIntercepting Filters Design Pattern
Intercepting Filters Design Pattern
 
Creating Dynamic Objects PHP
Creating Dynamic Objects PHPCreating Dynamic Objects PHP
Creating Dynamic Objects PHP
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

File Management Basics Part 1 PHP

  • 2. Overview Objective Learn how to create, copy and delete files within a file system using PHP and ProdigyView. Requirements  Access read/write access to various locations in a file system Estimated Time 5 Minutes
  • 3. Follow Along With Code Example 1. Download a copy of the example code at www.prodigyview.com/source. 2. Install the system in an environment you feel comfortable testing in. 3. Proceed to examples/util/FileManagement1.php
  • 4. What is File Management File management is the process of reading and writing a file. If you have performed reading and writing files in PHP, you may have come across minor frustration if fread() and fwrite() are being used. You may also have come across problems with encoding issues or questions on how to copy entire directories. ProdigyView takes care of those difficulties for you.
  • 5. File Locations Let’s begin this example with creating the directories the file will be placed in. If you remember the PV_FILE defines, it sets the location in your file system to place files.
  • 6. Writing A File Writing a file is accomplished with this method: Passing the variables to this function break down like this.  $file: The location of the file to write  $content: The contents to put in the file  $mode : The mode in writing the file. The default is ‘w’ which means write only. If you pass ‘a’, that will append to the file.  $encoding: By default, no encoding is added to a file but you can always add one.
  • 7. Write a File Code With our previous variables set up, lets write information to a file. 1. File Location 2. Content to write to file 3. Append content to file 4. Set the encoding
  • 8. Reading A File Reading a file has similar options of writing a file. To read a file, this function is used:  $file: The location of the file to read  $mode: The mode to use when reading the file. The same mode options are used that are used in fopen() function can be used here.  $encoding: Default is no encoding, but an encoding can be used for the file being returned.
  • 9. Reading File Example Now that you have the functions for writing and reading a file, lets put our code to use. `. Read the file from a location 2. Set the mode for reading a file 3. Set the encoding for the file
  • 10. New File Only! Now that we have basics for writing and reading a file, lets implement some file protection. Using the function writeNewFile() takes in the exact same parameters as writeFile, except it checks if the file exist first. Will write a file only if it does not exist
  • 11. Write File Only If It Exist The opposite of of writeNewFile() is to rewriteNewFile(). This function will only write to a file if it already exist. 1. Write to file only if it exist 2. Read the file
  • 12. Directories One of the things ProdigyView tries to make easier to manage is directories. ProdigyView provides the ability to copy entire directories and the ability to delete directories will relative ease. 1. Set directory to copy 2. Set location to copy directory 3. Delete an entire directory
  • 13. Review 1. Write a file with PVFileManager::writeFile() method. 1. PVFileManager::writeNewFile() will only write a file if it DOES NOT already exist. 2. PVFileManager::rewriteNewFile() will only write a file if it DOES exist 2. Read a file using PVFileManager::readFile() method. 3. Copy directories using PVFileManager::copyDirectory() method. 4. Delete A directory by using PVFileManager::deleteDirectory() method.
  • 14. API Reference For a better understanding of file management in ProdigyView, visit the api by clicking on the link below. PVFileManager More Tutorials For more tutorials, please visit: http://www.prodigyview.com/tutorials www.prodigyview.com