When i upload a file to my databae i want it to get the user_id, but it is returning null.
I already have made some tests to check if its really returning null and it is once i upload.
It knows which user_id is logged on that upload page.
See my code:
<?php
if(isset($_POST['title']))
{
//Check file type
$ext = substr(strrchr(basename($_FILES['file']['name']), '.'), 1);
if (!in_array($ext, $okExts))
{
echo "<p class=\"bad\">Formato Inválido.</p>";
}
else
{
$movePath = "../".$uploadPath . basename($_FILES['file']['name']);
$url = basename($_FILES['file']['name']);
$title = mysql_escape_string($_POST['title']);
$description = mysql_escape_string($_POST['description']);
$user_id = $_GET['user_id'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $movePath))
{
//Update Fields
$fileSQL = "INSERT INTO files (title, description, user_id, url)
VALUES ('$title', '$description', '$user_id','$url')";
mysql_query($fileSQL,$conn) or die('Error: ' . mysql_error());
echo "<p class=\"good\">O Arquivo ".basename( $_FILES['file']['name'])." foi enviado.</p>";
}
else
{
echo "Ocorreu um erro ao enviar o arquivo, por favor tente novamente!";
}
}
}
?>