Example 13 - PHP Create a file write and read the contents inside files TextEdit. Part-II

Опубликовано: 04 Октябрь 2024
на канале: Priyanka Jamdar
296
5

In the above example
First create three field using HTML script (form with method=”post”)
i)Input textbox field : this is text field where user enters the file name
ii) select box : user selects the extension of file.
iii)textarea : user enters the content(data).
and a submit button with value =”Save”.
When user click on save button logic define inside PHP script perform their execution.
first it check the existence using isset($_POST[‘save’]). $_POST[‘file’], $_POST[‘ext’], $_POST[‘data’], is used to collect the values from a HTML form.
$file variable store the concatenation of file name and extension using($f.$ext).
Now check the existence of file using file_exists( ) function. if its true message show file is already exist. otherwise else condition execute . open the file using fopen () function pass two argument($file,”w”) w is used to write on file. function fwrite( ) with two arguments($fo,$data) write data on a file.
message is shown “your file saved”.


Github Link: https://github.com/priyanka2907/PHP/b...