tags:

views:

17

answers:

1

Hi, 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 most 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!

+1  A: 

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.

Riateche
I've found the problem, in order for it to be displayed in the browser correctly i need to save the file as UTF-8 as at the moment its saved as UNICODE... is there a way around making the file convert to UTF-8 without the user having to do this them self?
joe khan
mb_convert_encoding can convert files but using the "AUTO" does not find the specified character sadly :(
joe khan