Help with uploaded filename into db needed

I’m using the following to upload a file, which I later put into MySQL database:

if ($_FILES[“upload”][“error”] > 0)
//echo "Return Code: " . $_FILES[“upload”][“error”] . “<br />”;
“upload/” . $_FILES[“upload”][“name”]);
echo "Stored in: " . “upload/” . $_FILES[“upload”][“name”];


How do I get the filename, which should be stored in “upload” (my understanding) into the field “filename” in the database?

I’m using $sql = ("INSERT INTO dbname (…, filename) VALUES (…, ‘what would I put here inside single quotes?’);

I’ve tried $upload = ‘upload’ with then $upload in the VALUES portion, but of course that gives me the word upload in the db. Same if I just use ‘upload’ or ‘name’.

Help would be appreciated. Thanks.


$Query = “INSERT INTO table (…, filename) VALUES (… ,'upload/” . $_FILES[‘upload’][‘name’] . "')

I believe is what you are after.

Thanks. I just figured it out along the same lines by putting in

$sql1 = $_FILES[“upload”][“name”];

then putting ‘$sql1’ in the VALUES.

Your way is cleaner, so I’ll use it, plus it gives the path. Thanks again.