Tue Jun 23 2020
Create Delete File
PHP Scripting2789 views
File Name: create-delete-file.php
<?php
/* Create new file */
$filename = "myFile.txt";
/* Open file in write mode */
$file = fopen($filename, "w") or die("Unable to open file!");
$txt = "My first file!";
/* Write text into file */
fwrite($file, $txt);
/* Close file */
fclose($file);
echo "File created successfully!<br />";
/* Delete file */
/* Checking is file exist or not */
if(is_file($filename)) {
/* Unlink(delete) file */
if(unlink($filename))
echo "File deleted successfully!";
else
echo "File can't be delete...try again!";
}
else
echo "File no found!";
?>
/* Output */
File created successfully!
File deleted successfully!
Author:Geekboots