This is an coding for uploading of word,pdf,and ppt file in an database. where as the file below 1Mb are stored in database but the file above 1mb show the below error........
Error........
Warning: mysql_query() [function.mysql-query]: MySQL server has gone away in C:\wamp\www\WOR K CENTER\profile. php on line 21
Warning: mysql_query() [function.mysql-query]: Error reading result set's header in C:\wamp\www\WOR K CENTER\profile. php on line 21
Error........
Warning: mysql_query() [function.mysql-query]: MySQL server has gone away in C:\wamp\www\WOR K CENTER\profile. php on line 21
Warning: mysql_query() [function.mysql-query]: Error reading result set's header in C:\wamp\www\WOR K CENTER\profile. php on line 21
Code:
<?php
// uploadAction.php
include('config.php');
if($_SERVER["REQUEST_METHOD"] == "POST")
{
if (($_FILES["form_data"]["type"] == "application/pdf")
|| ($_FILES["form_data"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|| ($_FILES["form_data"]["type"] == "application/msword")
|| ($_FILES["form_data"]["type"] == "application/vnd.openxmlformats-officedocument.presentationml.presentation")
|| ($_FILES["form_data"]["type"] == "application/vnd.ms-powerpoint"))
{
$id= mysql_insert_id();
$file = $_FILES['form_data']['name'];
$file_tmpName = $_FILES['form_data']['tmp_name'];
$file_size = $_FILES['form_data']['size'];
$file_type = $_FILES['form_data']['type'];
$file_section = $_POST["section"];
$data=addslashes(fread(fopen($file_tmpName,"r"),filesize($file_tmpName)));
$queryUser = "INSERT INTO upload (id,data,name,size,type,section) VALUES('$id','$data','$file', '$file_size','$file_type','$file_section')";
$insert = mysql_query($queryUser);
if(!$insert)
{
echo "<div class='f_upload'>upload fail</div>";
}
else
{
echo "<div class='f_upload'>file uploaded successfully</div>";
}
}
else
{
echo "<div class='f_upload'>Invalid file Plz check ur file</div>";
}
}
?>
Comment