开发者

characters added when reading temp file

when i do a direct input feild as text the input comes through fine but when i change the input feild type to "FILE" and then read the temp contents stored on the server it adds extra characters that are "unknown"

$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp = fopen($tmpName, 'r');
$content = fread($fp, $fileSize);
fclose($fp); 

echo $content;

Its most probably to do with secuirty but how do i change the content so it reads normal? In firefox it comes up with square boxes for mo开发者_StackOverflow中文版st characters with the letters: Here is an example:

Its meant to say: "Dirty Rocker" but instead comes out like this: "D�i�r�t�y� �R�o�c�k�e�r"

Hope you can help!


Set data type in form to multipart/form-data. Set encoding of output page to utf-8 through header and meta tag.

Check real contents of uploaded file. Compair original file and its copy on the server. Try to upload file manually (though ftp, for example) and read it by php.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜