I'm modifying a page that handles content addition. I've been tasked with allowing simple PDF file uploads, but can't figure it out. The PDF is to be posted, then uploaded and the title saved into a database field. All this functionality is to be contained within the one content addition page. Below is a summary snippet indicating the layout and general method...


<form action="" enctype="multipart/form-data" method="post">
<input type="text" name="one">
<input type="text" name="two">
<input type="text" name="three">
[U]<input type="file" name="pdf"/> [/U]
<input type="submit" value="Add" name="add_content"/>



$one	= stripslashes($_POST['one']);
$two 	= stripslashes($_POST['two']);

$sql    = inserts using the variables above;
$query = mysql_query($sql);


How do I access the posted file when the initial form has been posted and its relevant function invoked? Both initial lines below assign the name of the file to the variable - so when trying to access the type, name, size etc - only the name is found. Any help would be much appreciated.

$file = $_POST['file'].$_FILES['file'];
$file = $_POST['file'];

echo "<br>Type: ".$file.$_FILES['file']['type'];
echo "<br>Name: ".$file.$_FILES['file']['name'];
echo "<br>Size: ".$file.$_FILES['file']['size'];

If a thread is marked solved, shouldn`t there be a visible solution to others that may land here thru searching?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.