0

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...

if(!isset($_POST['add_content'])):

<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"/>
</form>

endif;

if(isset($_POST['add_content'])):

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

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

endif;

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'];

Edited by InfernalEternal: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by phoenix_2000
1

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.