PHP File Handling(file system)

The file system functions allow you to access and manipulate the file.

file system provides a concept to start a specific data using different types of file format.

That means file gives us linear type database concept. There is no any type of relations will be found with value because it doesn’t support RDBMS concept.

Through this concept you will retrieved data from disk files, XML documents and many other data sources.

Files In a computer, a file system (sometimes written filesystem) is the way in which files are named and where they are placed logically for storage and retrieval.

The DOS, Windows, OS/2, Macintosh, and UNIX-based operating systems all have file systems in which files are placed somewhere in a hierarchical (tree) structure.

A file is placed in a directory (folder in Windows) or sub-directory at the desired place in the tree structure.

How to Create a file using PHP

touch( ) function is used to create a file

Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be created


How to Delete a file using PHP

unlink( ) function is used to delete a file

Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be deleted


How to copy a file using PHP

copy( ) function is used to copy file
Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be copied with new name

How to Rename file using PHP

rename( ) function is used to rename file.
Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be renamed

Checks whether a file or directory exists

file_exists( ) function is used to check file or directory existence.
Syntax

Eg

Output
It returns true(1) if file exists
otherwise return false(blank screen)


Check size of the file in PHP

filesize( ) function is used to check file size.
Syntax

Eg

Output
0 Bytes

Check Path of the file in PHP

realpath( ) function is used to check real path of the file.
Syntax

Eg

Output
C:xampplitehtdocsYoufProjectfileName with extension
//OR
C:wampwwwYoufProjectfileName with extension


  • BalaNagaPrasad M

    Hi Sanjeev,
    Its very Nice Site. You are giving Good information about PHP and HTML.
    Thank you Sanjeev. :)

    • http://www.phptpoint.com Sanjeev Rai

      Thank you very much

  • saranyagangadharan

    I WANT PROGRAM IN PHP MYSQL FOR DISPLAYING CITIES BY SELECTING A STATE, all cities and states must be fetch from my sql..

  • saranyagangadharan

    thank u but i have a doubt why we are using ajax here? can u pls suggest a simple code without ajax for the same concept

    • http://www.phptpoint.com Sanjeev Rai

      Will Update and provide u link soon

  • Chaitanya Bhatt

    Hello sir… Can I get the upload popup code ..???

  • jai

    hello sir. how can connect our database and other database using php ? can you send me code Plz

    • http://www.phptpoint.com Sanjeev Rai

      Hello Jai
      can you tell me more about your query….

  • Ram Moorthy

    i need this page code job search page find job key word function

    • http://www.phptpoint.com Sanjeev Rai

      This is an api provided by third party.

  • Dipen Parmar

    Thanks sir