hi everyone :)
i dont know where i am doing it wrong...but cant upload my file...there is no error but its not saving the whole path in DB and not uploading anything in the directroy as well... please point me to riht direction tahnx :)
<?php include("../includes/config.php");?>
<?php
$mediafile = $_FILES['uploadedfile']['name'];
$allowedExts = array("jpg", "jpeg", "gif", "png","txt","doc","pdf","mp3","mp4","ppt","avi","mov","moov","qt","flv","FLV");
$extension = end(explode(".", $_FILES["uploadedfile"]["name"]));
if (( ($_FILES["uploadedfile"]["type"] == "image/gif")
|| ($_FILES["uploadedfile"]["type"] == "audio/mpeg")
|| ($_FILES["uploadedfile"]["type"] == "audio/mp3")
|| ($_FILES["uploadedfile"]["type"] == "video/mp4")
|| ($_FILES["uploadedfile"]["type"] == "video/avi")
|| ($_FILES["uploadedfile"]["type"] == "video/quicktime")
|| ($_FILES["uploadedfile"]["type"] == "video/x-flv")
|| ($_FILES["uploadedfile"]["type"] == "application/msword")
|| ($_FILES["uploadedfile"]["type"] == "application/pdf")
|| ($_FILES["uploadedfile"]["type"] == "application/vnd.ms-powerpoint")
|| ($_FILES["uploadedfile"]["type"] == "text/plain")
|| ($_FILES["uploadedfile"]["type"] == "application/pdf")
|| ($_FILES["uploadedfile"]["type"] == "image/jpg")
|| ($_FILES["uploadedfile"]["type"] == "image/gif")
|| ($_FILES["uploadedfile"]["type"] == "image/png")
|| ($_FILES["uploadedfile"]["type"] == "image/pjpeg"))
&& in_array($extension, $allowedExts))
{
if ($_FILES["uploadedfile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["uploadedfile"]["error"] . "<br />";
}
elseif (file_exists("graphics/learningmaterial/" . $_FILES["uploadedfile"]["name"]))
{
echo $_FILES["uploadedfile"]["name"] . " already exists. ";
}
//$target_path = "graphics/learningmaterial/";
$imgdir = "graphics/learningmaterial/";
$imgname = $imgdir.$mediafile;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $imgname))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
}
}
else
{
echo "There was an error uploading the file, please try again!";
}
?>
<?php
$title=$_POST['title'];
$url=$_POST['url'];
$source=$_POST['source'];
$description=$_POST['description'];
$extid=$_POST['external_id'];
$filename=$_POST['internalfilename'];
$filesize=$_POST['internalfilesize'];
$duration=$_POST['externalduration'];
$courseid=$_POST['coursesid'];
$type=$_POST['type'];
$order=$_POST['order'];
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
$sql=("INSERT INTO learningmaterial VALUES (NULL,'".$title."', '".$url."','".$source."','".$description."','".$extid."','".$filename."','".$filesize."','".$imgname."','".$duration."','".$courseid."','".$type."','".$order."')");
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
else {
echo header("Location:manage-material.php?status=1&id=".$courseid);
}
//echo header("Location:manage-material.php?status=1&id=".$courseid);
//echo header ($_FILES['uploadedfile']['type']);
exit();
mysql_close($con);
?>