newbie: file upload

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have little experience in PHP and I need to implement file upload in my  
first website in PHP5.
I have created Paper.php page with such form:

<h3>Add Edition</h3>
Enter local file path of the paper, fill in fields and press 'Send  
<form id="AddEdition" name="AddEdition" action="AddEdition.php"  
method="POST" enctype="multipart/form-data" onsubmit="return  
 <table border="0">
  <td>File .doc or .docx:</td>
   <input type="file" id="SelectEditionFile" name="SelectEditionFile"  
width="50%" onblur="PassFile();" />
   <input type="hidden" value="" id="EditionFile" name="EditionFile" />
  <td><input type="submit" value="Send file" /> <input type="reset"  
value="Cancel" /></td>
<script type="text/javascript">
function PassFile()
 document.getElementById('EditionFile').value =  

The form uses AddEdition.php file:


include('');    // contains ValidateEdition()

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['EditionFile']))
 if (!ValidateEdition())
  $_SESSION['Error'] = 'Edition data was not accepted.';
  if (is_uploaded_file($_FILES['EditionFile']['tmp_name']))    // HERE  
   $file = $_FILES['EditionFile']['name'];
   $ext = @substr($file,
           @strrpos($file, '.') ? @strrpos($file, '.') + 1 : @strlen($file),
   if (!move_uploaded_file($_FILES['EditionFile']['tmp_name'],
    'Paper/Paper.' . $ext))
    $_SESSION['Error'] = 'File not available.';
   $_SESSION['Error'] = 'File not sent.';
header("Location: Paper.php?topic=Editions");

The problem is that is_uploaded_file returns false, I don't know why.
Could you help me plase?

Re: newbie: file upload

Quoted text here. Click to load it

The file field name is "SelectEditionFile" not EditionFile

Quoted text here. Click to load it

Should be is_uploaded_file($_FILES['SelectEditionFile']['tmp_name'])

Site Timeline