Hi all..i have a problem that i want to upload file less than 5MB..but it doesn't work for file size more than 3MB..what happen huh? Please help me..

<?php

include "connection/db_connect.php";
include "template.php";
$reqid=$_GET['reqid'];

 if (($_FILES["file"]["type"])
 && ($_FILES["file"]["size"] < 5000000000000))
   {
   if ($_FILES["file"]["error"] > 0)
     {
     echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
     }
   else
     {
     $filename = $_FILES["file"]["name"];
     $filetype =  $_FILES["file"]["type"];
     $size =  ($_FILES["file"]["size"]/ 1024);
     $path =  $_FILES["file"]["tmp_name"];
	 $dir = "upload/" . $_FILES["file"]["name"];
	 
	 $query = "INSERT INTO attachment (reqid, fileName, size, fileType,tmpName ) ".
			  "VALUES ('$reqid', '$filename', '$size', '$filetype', '$dir')";

	 mysql_query($query) or die('Error, query failed : ' . mysql_error());
 
    if (file_exists("upload/" . $_FILES["file"]["name"]))
       {
       echo  "<script language='javascript'>alert('Sorry! File already exists. Please change the filename' );</script>";
       }
     else
       {
       move_uploaded_file($_FILES["file"]["tmp_name"],
       "upload/" . $_FILES["file"]["name"]);
       echo $dir;
       }
     }
   }
 else
   {
   echo "<script language='javascript'>alert('Sorry!! File should be less then 5MB!');</script>"; 
   }
 
 ?>

Well it doesn’t work, what is the message? … Have you checked your php.ini for max upload file size ?

Sometime it show error

Error, query failed : Data too long for column 'size' at row 1

Thanks for reply "jkon"

erm...sorry..how can i check it??

Well my friend, the message is telling you what is wrong , Data too long for column 'size' . What is the result of “SHOW CREATE TABLE attachment” that you defined the column 'size' ?

what datatype you have used for size in your attachment table?

i define the column 'size' 5.. because i don't want it show longer size (exp : 543.8789789) actually the file size that i want to upload is 3582KB.. but not allowed to upload..

Thanks for reply "Karthik_pranas"...
i use varchar(5)

Just maths
You say

$_FILES["file"]["size"] < 5000000000000)

And then

$size =  ($_FILES["file"]["size"]/ 1024);

So size could be 5000000000000/1024 which is 4882812500 so it isn’t 5 digits number …

commented: yes +7

Change your varchar length as varchar(10)

hurm.. than i change my code but still not work for file 3582KB..

if (($_FILES["file"]["type"])
 && ($_FILES["file"]["size"] < 5000000))

Dear Karthik_pranas;
it still same error.. :(

to both of you..
now i change my code n data size for table attachment to varchar(15)

i work but for file 3000Kb and above doesn't work..hurm..

if (($_FILES["file"]["type"])
 && ($_FILES["file"]["size"] < 5000000))

doesn't work isn't the message you got ...

no error message..but cannot upload..

OMG!! i have solved my problem, actually i need to change the max file size in php.ini.. TQVM for help.. :)