[SOLVED] Filesize != Filesize

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nyk
Forum Newbie
Posts: 13
Joined: Mon Nov 22, 2004 8:07 pm
Location: Berne, Switzerland
Contact:

[SOLVED] Filesize != Filesize

Post 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.)
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

filesize != strlen

Two different functions, two different results.
nyk
Forum Newbie
Posts: 13
Joined: Mon Nov 22, 2004 8:07 pm
Location: Berne, Switzerland
Contact:

Post by nyk »

AH, I had to use fread instead of file(), because the latter is NOT binary-safe, obvously.... Now it works finally!
Post Reply