0
File Management Basics
OverviewObjectiveLearn how to create, copy and delete files within a filesystem using PHP and ProdigyView.Requirements Ac...
Follow Along With Code Example 1. Download a copy of the example code at   www.prodigyview.com/source. 2. Install the syst...
What is File ManagementFile management is the process of reading and writing afile.If you have performed reading and writi...
File LocationsLet’s begin this example with creating the directories thefile will be placed in. If you remember the PV_FIL...
Writing A FileWriting a file is accomplished with this method:Passing the variables to this function break down like this....
Write a File Code With our previous variables set up, lets write information to a file.1. File Location      2. Content to...
Reading A FileReading a file has similar options of writing a file. To reada file, this function is used:  $file: The loc...
Reading File Example  Now that you have the functions for writing and reading a  file, lets put our code to use.`. Read th...
New File Only!Now that we have basics for writing and reading a file, letsimplement some file protection. Using the functi...
Write File Only If It ExistThe opposite of of writeNewFile() is to rewriteNewFile().This function will only write to a fil...
Directories One of the things ProdigyView tries to make easier to manage is directories. ProdigyView provides the ability ...
Review1. Write a file with PVFileManager::writeFile() method.  1. PVFileManager::writeNewFile() will only write a file if ...
API ReferenceFor a better understanding of file management inProdigyView, visit the api by clicking on the link below.PVFi...
Upcoming SlideShare
Loading in...5
×

File Management Basics Part 1 PHP

1,327

Published on

Learn how to read, write and copy directories and fills in ProdigyView using PHP

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,327
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "File Management Basics Part 1 PHP"

  1. 1. File Management Basics
  2. 2. OverviewObjectiveLearn how to create, copy and delete files within a filesystem using PHP and ProdigyView.Requirements Access read/write access to various locations in a file systemEstimated Time5 Minutes
  3. 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. 4. What is File ManagementFile management is the process of reading and writing afile.If you have performed reading and writing files inPHP, you may have come across minor frustration iffread() and fwrite() are being used. You may also havecome across problems with encoding issues or questionson how to copy entire directories.ProdigyView takes care of those difficulties for you.
  5. 5. File LocationsLet’s begin this example with creating the directories thefile will be placed in. If you remember the PV_FILEdefines, it sets the location in your file system to placefiles.
  6. 6. Writing A FileWriting 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. 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. 8. Reading A FileReading a file has similar options of writing a file. To reada 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. 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. 10. New File Only!Now that we have basics for writing and reading a file, letsimplement some file protection. Using the functionwriteNewFile() takes in the exact same parameters aswriteFile, except it checks if the file exist first. Will write a file only if it does not exist
  11. 11. Write File Only If It ExistThe 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. 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. 13. Review1. 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 exist2. Read a file using PVFileManager::readFile() method.3. Copy directories using PVFileManager::copyDirectory() method.4. Delete A directory by using PVFileManager::deleteDirectory() method.
  14. 14. API ReferenceFor a better understanding of file management inProdigyView, visit the api by clicking on the link below.PVFileManager More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×