How do I add a file size limit to my upload form code (below)?
Is this correct?
if ( $_FILES["file"]["size"] < 100000
Where can I add it to make it functional?
Do I need any additional code to make that line of code functional?
This is a 100kb limit correct?
How/where can I add in an error message, - if the file size is over the limit?
$allowedExts = array("gif", "jpeg", "jpg", "pdf", "doc", "docx", "txt", "rtf", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = strtolower( end($temp) );
if (!in_array($extension,$allowedExts))
{
echo ("Error - Invalid File Name");
}
$length = 20;
$randomString = (time());
$thumbnail = $_SESSION['user_id'] . '-' . $randomString . "." . $extension;
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
$sql = "INSERT INTO videos ( filename ) VALUES( '$thumbnail' )";
mysql_query($sql);
$file_location = '<a href="http://www.......com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
Thanks. I look forward to any help.