I have a form to upload a file. When I try to read said file, it is always empty. The HTML specification states that the file contents are transmitted from client to server in the parameter list. Now, it's very easy to access that file's name in php just by using $filename, but there's no "variable name" for the actual file contents. Is there any way to access those contents without having to open the file, since it's sent as part of the parameters? I don't want to save this file at all, just parse some things out of it and then discard it.
Here's some code I'm using:
Type in a file name, or click the "Browse" button to search for a file on your computer.<br><br>
<input type="hidden" name="MAX_FILESIZE" value="10240">
<input type="file" name="fileIn">
I did set enctype to multipart/form-data.
I tried reading in the file like so, and the file came up empty. (or at least, it didn't write anything out)
if(isset($fileIn)){
echo $fileIn;
//open file and check if opened properly
if(!($myFile = fopen($fileIn, "r"))){
print("error: ");
print("'$fileIn' could not be read\n");
exit;
}
while(!feof($myFile)){
//read a line
$myLine = fgets($myFile, 225);
print("$myLine bob<BR>\n");
}
//close file
fclose($myFile);
}
thanx,
karassa