It changes the current directory on a FTP server
Example
<?php
$fName = “/home/user/test.txt”;
$ftpId = ftp_connect(‘ftp.phpcodez.com’);
$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);
ftp_chdir($ftpId, ‘phpcodez’);
?>
It changes the current directory on a FTP server
Example
<?php
$fName = “/home/user/test.txt”;
$ftpId = ftp_connect(‘ftp.phpcodez.com’);
$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);
ftp_chdir($ftpId, ‘phpcodez’);
?>
It changes to the parent directory
Example
<?php
$fName = “/home/user/test.txt”;
$ftpId = ftp_connect(‘ftp.phpcodez.com’);
$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);
ftp_chdir($ftpId, ‘phpcodez’);
ftp_cdup($ftpId) or die(“Failed”);
echo ftp_pwd($ftpId);
?>
It allocates space for a file to be uploaded
Example
<?php
$fName = “/home/user/test.txt”;
$ftpId = ftp_connect(‘ftp.phpcodez.com’);
$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);
ftp_alloc($ftpId, filesize($fName), $result) or die($result);
ftp_put($ftpId, ‘temfileName’, $file, FTP_BINARY);
ftp_close($ftpId);
?>
It deletes the file
Example
<?php
unlink(“test.txt”) or die(“Failed”);
?>
It changes file permissions of file
Example
<?php
$file = umask(0);
chmod(“test.txt”, 0755);
umask($file)
?>
It sets access and modification time of file
Example
<?php
touch(“test.txt”);
?>
It creates a temporary file
Example
<?php
$fp = tmpfile();
fwrite($fp, “phpccodez”);
rewind($fp);
echo fread($fp,1024);
fclose($fp);
?>
Output
phpccodez
It create file with unique file name
Example
<?php
echo tempnam(“/var/www/test/”,”test.txt”);
?>
Output
/var/www/test/test.txtcpijNs
It creates a symbolic link
Example
<?php
$link = ‘test’;
symlink(“test.txt”, $link);
echo readlink($link);
?>
Output
test.txt
It returns information about a file
Example
<?php
echo “<pre>”;
print_r(stat(“test.txt”));
?>
Output
Array
(
[0] => 2049
[1] => 673769
[2] => 33279
[3] => 1
[4] => 33
[5] => 33
[6] => 0
[7] => 8
[8] => 1336816154
[9] => 1336816154
[10] => 1336816154
[11] => 4096
[12] => 8
[dev] => 2049
[ino] => 673769
[mode] => 33279
[nlink] => 1
[uid] => 33
[gid] => 33
[rdev] => 0
[size] => 8
[atime] => 1336816154
[mtime] => 1336816154
[ctime] => 1336816154
[blksize] => 4096
[blocks] => 8
)