I am trying to upload a pdf file using fileupload() function in php. This works great when no session is used but gives an error with session.
This is how I defined a session:
session_start();
if(isset($_SESSION['name']))
{
$name=$_SESSION['name'];
$_SESSION['name']=$name;
and here is the fileupload() function:
function fileupload()
{
$corname = $_POST['corname'];
define ("FILEREPOSITORY","./upload");
$filename = './upload/'.$corname.'.pdf';
//echo $filename;
if (is_uploaded_file($_FILES['file']['tmp_name']))
{
if ($_FILES['file']['type'] != "application/pdf")
{
echo "<p>Class notes must be uploaded in PDF format.</p>";
}
else if(file_exists($filename))
{
echo "already exist";
}
else
{
//$name = $_POST['corname'];
$result = move_uploaded_file($_FILES['file']['tmp_name'], FILEREPOSITORY."/$corname.pdf");
if ($result == 1)
{echo "<p>File successfully uploaded.</p>";
$cata=$_POST['cata'];
$subcata=$_POST['subcata'];
$corname = $_POST['corname'];
$heading=$_POST['headng'];
$descrip=$_POST['descrip'];
$cno=$_POST['cno'];
$credit=$_POST['credit'];
$fee=$_POST['fee'];
$qry="insert into course (catagory,subcatagory,courseno,coursename,heading,description,credit,fee,coursefilename) values ('$cata','$subcata','$cno','$corname','$heading','$descrip','$credit','$fee','$corname')";
$ins_qry=mysql_query($qry);
if($ins_qry)
{
echo "Successfully Inserted<br>";
}
else
{
echo mysql_error();
}}
else {echo "<p>There was a problem uploading the file.</p>";}
} #endIF
} #endIF
}}
This is the error message I get:
Fatal error: Call to undefined function fileupload() in C:\wamp\www...\course_submit_process.php on line 66
I have checked everything for some error but can't reach for any solution. Please let me know if I am missing something.
Thanks in advance.
undefined function fileupload, that's a hint :)undefined function error not session