|
Posted by Matthias Langbein on 07/22/06 23:16
Hi all,
on one of my sites I want to give the user the possibility to upload a
html file where I want to extract all that is within the <body>-tags.
The upload works fine:
<form id="uploadform" action="index.php" method="post"
enctype="multipart/form-data">
<input type="file" name="Datei" size="30"/>
<input type="submit"/>
</form>
Then I want to parse the uploaded file with:
<?php
if (isset($_FILES['Datei']) and !$_FILES['Datei']['error']) {
$buffer = file_get_Contents($_FILES['Datei']['tmp_name']);
echo "body: ".$buffer."\n";
}
?>
I get a weird result:
body: ÿþ< h t m l > < h e a d > < t i t l e < / t i t l e > .....
So there seem to be some white spaces between every character.
And then there is no way to find the <body>-tag.
Neither
echo "sub: ".strpos($buffer, "< b o d y")."\n";
nor
echo "sub: ".strpos($buffer, "<body")."\n";
works. Both show no result.
Can anybody explain me this? How can I parse the file to extract
everything which is within the <body>-Tags (possibly without the white
spaces)?
Thanks a lot,
Langi
Navigation:
[Reply to this message]
|