PHP Tutorial-File Read - General Pleasure

My dedication is to show general knowledge such as health, technology, resorts, cleanliness, popularity of traditional ways, how to make money online, and how to agree, publish our site, and up-to-date tutorials such as Excel, HTML, Powerpoint . we try to find good tips to show you, If you have any questions, please contact us my by e-mail Thank you for coming to our site. Thank you.

Home Top Ad

RESPONSIVE ADS HERE

Post Top Ad

Your Ad Spot

Friday, July 3, 2020

PHP Tutorial-File Read

PHP Tutorial-File Read

PHP-File Open: read 

    Before we can information from a file we have to use the function fopen to open the file for reading. Here's the Code to read- Open the File we created in the PHP file Write Lessons.


PHP Code: 
    The file we created in the last lesson was names "test1.txt". Your PHP script that you are writing should reside in the same directory as "test.txt"
    
   My Video 
Code 1:
<html>
<head>
</head>
<body>
<h1> Knowledge Edcuation Cambodia </h1>
<form method="post" enctype="multipart/form-data" action="readdata.php">
<input type="file" name="myfile">
<input type="submit" value="readdata">
</form>
</body>
</html>

Note: File->Save->index.php

Code 2:
<?php
$myfile=$_FILES["myfile"];
$path=$myfile["tmp_name"];
$type=$myfile["type"];
if($type=="text/plain"){
if(file_exists($path)){
if(is_readable($path)){
$object=fopen($path,"r");
while(!feof($object))
{
$line=fgets($object);
$line=htmlspecialchars($line);
echo $line;
echo "<br/>";
}
}
else
{
echo "the file is not reading format";
}
}
else{
echo "file not Exits";
}
}
else
{
echo "No text file";
}
?>
Note: file->save-readdata.php


Post Top Ad

Your Ad Spot