You are here: white spaces in uploaded html file « PHP Programming Language « IT news, forums, messages
white spaces in uploaded html file

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация