I'm making a system for adding files to a database. I use a form:
<form action="insert.php" method="post" enctype="multipart/form-data">
Fil: <input type="file" name="file" id="file">
Titel: <input type="text" name="titel" /><br />
Längd (min): <input type="text" name="langd" /><br />
Medverkande: <input type="text" name="medverkande" /><br />
Reporter: <input type="text" name="reporter" /><br />
Fotograf: <input type="text" name="fotograf" /><br />
Sökord: <input type="text" name="sokord" /><br />
<input type="submit" />
</form>
The code in insert.php:
<?php
$con = mysql_connect("database","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("165666-kltvplay", $con);
$filnamn = $_FILES["file"]["name"] ;
$sql="INSERT INTO Blad1 (ProgramID, Titel, Langd, Medverkande, Reporter, Fotograf, Sokord)
VALUES
('$filnamn','$_POST[titel]','$_POST[langd]','$_POST[medverkande]','$_POST[reporter]','$_POST[fotograf]','$_POST[sokord]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "En ny film inlagd: <br> ";
echo $filnamn;
mysql_close($con);
?>
But when I add the file it seems to be uploading the whole file because there is a % counter in my browser and it's taking a loooong time to complete(the files are qute big). I just want the name of the file inserted into the database (and that is working) but not to upload the whole file.
And is it possible to add just the name and not the file exetension?