You are here: newbie: file upload « PHP Programming Language « IT news, forums, messages
newbie: file upload

Posted by R.A.M. on 12/22/07 06:04

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:

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

The form uses AddEdition.php file:

<?php
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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация