PHP file upload unexpected error - file too large?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.

Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.

$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// ---------------------  up to here the execution is correct and fast (<1

$sql="INSERT INTO $table (".
    " file_name,".
    " file_type,".
    " file_size,".
    " bin_data)".
    " VALUES (".
    " '$file_name',".
    " '$file_type',".
    " '$file_size',".
    " '$data')";
// --------------------- it gets stuck
mysql_query($sql) or die ("SQL error ..$sql");

I have already set the php.ini variables as follows:
    memory_limit = 16M
    upload_max_filesize = 6M

I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM

Any suggestion? Am I missing out something?

Thanks in advance,

Site Timeline