HELP, PHP MySQL fail to Uploading file more then 1mb

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
adisonz
Forum Newbie
Posts: 11
Joined: Wed Feb 08, 2006 2:09 am

HELP, PHP MySQL fail to Uploading file more then 1mb

Post by adisonz »

HELP, PHP MySQL fail to Uploading file more then 1mb ,

Code: Select all

$sub_id = $_SESSION["subid"];
        $fileName = $_FILES['userfile']['name']; 
        $tmpName  = $_FILES['userfile']['tmp_name']; 
        $fileSize = $_FILES['userfile']['size']; 
        $fileType = $_FILES['userfile']['type']; 
        $desc = $_POST['desc'];
		
		
        $fp = fopen($tmpName, 'r'); 
        $content = fread($fp, $fileSize); 
        $content = addslashes($content); 
        fclose($fp); 
         
        if(!get_magic_quotes_gpc()) 
        { 
            $fileName = addslashes($fileName); 
        } 
  
        $query = "INSERT INTO course_upload (sub_id, description, name, size, type, content) VALUES ('$sub_id','$desc','$fileName', '$fileSize', '$fileType','$content')"; 

		
		
		  
        mysql_query($query) or die('Error, query failed'.mysql_error());

my php.ini max file size is alreayd set to 2mb,
it has no problem when uploading file below 1mb , when i select a file more then 1mb will return an error "MySQL server has gone away".
Please help . assignment due date is near.
adisonz
Forum Newbie
Posts: 11
Joined: Wed Feb 08, 2006 2:09 am

Post by adisonz »

i am using mysql 5.01
i had changed the my-medium.ini max_allow_packet to 10mb and saved into the data folder as my.cnf
but still not working.

please correct me what i had done wrongly .
thank you
Post Reply