This is a discussion on Filesystem Object in PHP within the PHP Programming forums, part of the Web Development category; Hi, I am new to the Filesystem Object in PHP. I have used FileSystem Object in ASP. But no idea ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| hi, Actually The filesystem functions allow you to access and manipulate the filesystem. There are lot of functions or methods to manipulate files from your web server in PHP. As you say that, PHP Filesystem functions are more comfort while comparing with ASP
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| file:// is the default wrapper used with PHP and represents the local filesystem. When a relative path is specified (a path which does not begin with /, \, \\, or a windows drive letter) the path provided will be applied against the current working directory. In many cases this is the directory in which the script resides unless it has been changed. Using the CLI sapi, this defaults to the directory from which the script was called.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Explicitly using file://
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| No external libraries are needed to build this extension, but if you want PHP to support LFS (large files) on Linux, then you need to have a recent glibc and you need compile PHP with the following compiler flags: -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| allow_url_fopen enables the URL-aware fopen wrappers that enable accessing URL object like files. Default wrappers are provided for the access of remote files using the ftp or http protocol, some extensions like zlib may register additional wrappers. This setting can only be set in php.ini due to security reasons.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| other options are user_agent Define the user agent for PHP to send. default_socket_timeout Default timeout (in seconds) for socket based streams. from Define the anonymous ftp password (your email address). auto_detect_line_endings When turned on, PHP will examine the data read by fgets() and file() to see if it is using Unix, MS-Dos or Macintosh line-ending conventions. This enables PHP to interoperate with Macintosh systems, but defaults to Off, as there is a very small performance penalty when detecting the EOL conventions for the first line, and also because people using carriage-returns as item separators under Unix systems would experience non-backwards-compatible behaviour.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| basename() Given a string containing a path to a file, this function will return the base name of the file. If the filename ends in suffix this will also be cut off. On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/). example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| dirname() Given a string containing a path to a file, this function will return the name of the directory. On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/). example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In PHP 4.0.3, dirname() was fixed to be POSIX-compliant. Essentially, this means that if there are no slashes in path , a dot ('.') is returned, indicating the current directory. Otherwise, the returned string is path with any trailing /component removed. Note that this means that you will often get a slash or a dot back from dirname() in situations where the older functionality would have given you the empty string.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Another example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| chgrp () - attempts to change the group of the file filename to group (specified by name or number). Only the superuser may change the group of a file arbitrarily; other users may change the group of a file to any group of which that user is a member.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| This function will not work on remote files as the file to be examined must be accessible via the servers filesystem. When safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| chmod () attempts to change the mode of the file specified by filename to that given in mode. Note that mode is not automatically assumed to be an octal value, so strings (such as "g+w") will not work properly. To ensure the expected operation, you need to prefix mode with a zero (0): PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The mode parameter consists of three octal number components specifying access restrictions for the owner, the user group in which the owner is in, and to everybody else in this order. One component can be computed by adding up the needed permissions for that target user base. Number 1 means that you grant execute rights, number 2 means that you make the file writeable, number 4 means that you make the file readable. Add up these numbers to specify needed rights. You can also read more about modes on Unix systems with 'man 1 chmod' and 'man 2 chmod'. PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems. This function will not work on remote files as the file to be examined must be accessible via the servers filesystem. When safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed. In addition, you cannot set the SUID, SGID and sticky bits.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| chown () Attempts to change the owner of the file filename to user user (specified by name or number). Only the superuser may change the owner of a file.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| copy () function makes a copy of the file source to dest. Here some example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| As of PHP 4.3.0, both source and dest may be URLs if the "fopen wrappers" have been enabled. See fopen() for more details. If dest is a URL, the copy operation may fail if the wrapper does not support overwriting of existing files.
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Object Repositorys | simplesabita | Testing Tools | 1 | 08-22-2007 03:04 AM |
| object exceptions | simplesabita | Testing Tools | 1 | 08-22-2007 02:48 AM |
| Object reference not set to an instance of an object for crystal reports in .net | KiruthikaSambandam | Database Support | 1 | 08-03-2007 02:26 AM |
| Some DOM Object | ||||