• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How to read file in php?

I am running Apache server with php 4.0

This is the function of reading file.
I can read file when the file is in the computer of the server. If a client access the readfile function, it only know to search for the file in the server, but it suppose to read the file that is in client's computer. Therefore, when $TheFile is the path of file refer to client computer, there is warning message that "No such file or directory"

Does anyone know how to code in order to read the file in client's computer ??

function ReadFromFile($TheFile)
{

$Open = fopen ($TheFile, "r");

if($Open){
$Data = file ("$TheFile");
fclose($Open);
}
else{
print ("Unable to read from $TheFile!
\n");
}
return $Data;
}
 
Since PHP is a server side scripting language, it cannot (and should not be able to anyway) read files on the client side. No scripting language should be able to, although Java can.

If you need to read a file on the client side, use a form with a file input, and the file will be sent to the server, allowing the client (and user) to remain in full control of what is sent.

See more at: http://www.php.net/manual/en/features.file-upload.php
 
PHP is Server Side, unless the client uploads a file to the server, it cannot read the file.

PHP only can read what is on the server. That would be a nightmare if PHP coudl read files off clients computers wihtout upload...

 
Back
Top