newbie: file upload

newbie: file upload

am 22.12.2007 07:04:06 von r_ahimsa_m

Hello,
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:

Add Edition



Enter local file path of the paper, fill in fields and press 'Send
file':

method="POST" enctype="multipart/form-data" onsubmit="return
ValidateEdition();">









File .doc or .docx:
width="50%" onblur="PassFile();" />

value="Cancel" />





The form uses AddEdition.php file:

session_start();

include('Scripts.inc'); // contains ValidateEdition()

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['EditionFile']))
{
if (!ValidateEdition())
{
$_SESSION['Error'] = 'Edition data was not accepted.';
}
else
{
if (is_uploaded_file($_FILES['EditionFile']['tmp_name'])) // HERE
PROBLEM
{
$file = $_FILES['EditionFile']['name'];
$ext = @substr($file,
@strrpos($file, '.') ? @strrpos($file, '.') + 1 : @strlen($file),
@strlen($file));
if (!move_uploaded_file($_FILES['EditionFile']['tmp_name'],
'Paper/Paper.' . $ext))
{
$_SESSION['Error'] = 'File not available.';
}
}
else
{
$_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?
/RAM/

Re: newbie: file upload

am 22.12.2007 21:31:37 von Macca

>
The file field name is "SelectEditionFile" not EditionFile


> if (is_uploaded_file($_FILES['EditionFile']['tmp_name'])) // HERE
> PROBLEM



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