Write a menu driven program to perform various file operations. Accept filename from user. a) Display type of file. b) Display last access time of file c) Display the size of file d) Delete the file
HTML CODE:
<html>
<body>
<form action="c1.php" method="GET">
File Name : <input type="text" name="fname"><br>
<p>Which Operation do you want to perform ? </p>
<input type="radio" name="op" value="1">
<label for="Display">Display type of file</label><br>
<input type="radio" name="op" value="2">
<label for="atime">Display last accesss time of file</label><br>
<input type="radio" name="op" value="3">
<label for="size">Display size of file</label><br>
<input type="radio" name="op" value="4">
<label for="delete">Delete the file</label><br>
<input type="submit">
</form>
</body>
</html>
PHP CODE:
<?php
$file=$_GET['fname'];
$ch=$_GET['op'];
switch($ch)
{
case 1 : $t=filetype($file);
echo "File type : $t";
break;
case 2 : $a=fileatime($file);
echo " Last accesss time of file : $a";
break;
case 3 : $s=filesize($file);
echo "Size of file : $s";
break;
case 4 : $d=unlink($file);
echo "Deleted file successfully";
break;
}
?>
Comments
Post a Comment