Page 1 of 1

[SOLVED] Filesize != Filesize

Posted: Mon Nov 29, 2004 7:38 am
by nyk
This problem is making me insane:

Code: Select all

$ufn="tmp/".basename($_FILES['imgfile']['name']);
move_uploaded_file($_FILES['imgfile']['tmp_name'],$ufn);
$content_file=implode("", file($ufn));
$size1=$_FILES['imgfile']['size'];
$size2=strlen($content_file);
When I upload a 24kb imagefile I get this for size1 and size2:

Code: Select all

size1: 24739
size2: 17728
So WHY aren't they the same size, as they should be???

(This is the simplified main problem of this viewtopic.php?t=28117 question.)

Posted: Mon Nov 29, 2004 7:53 am
by patrikG
filesize != strlen

Two different functions, two different results.

Posted: Mon Nov 29, 2004 8:06 am
by nyk
AH, I had to use fread instead of file(), because the latter is NOT binary-safe, obvously.... Now it works finally!