Re: newbie: move_uploaded_file fails



R.A.M. wrote:
In the code below I cannot move uploaded file. I don't know why. The folder
Paper has priviledges rwxrwxrwx. $_POST['Year'] and $_POST['Month'] are
valid. Please help.
Thanks in advance!

<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['EditionFile']) && isset($_POST['Year']) &&
isset($_POST['Month']))
{
if (is_uploaded_file($_FILES['SelectEditionFile']['tmp_name']))
{
// Załaduj plik:
$file = $_FILES['SelectEditionFile']['name'];
$ext = @substr($file, @strrpos($file, '.') ? @strrpos($file, '.') + 1 : @strlen($file), @strlen($file));
$paper = 'Paper/Blask_' . $_POST['Year'] . '-' . $_POST['Month'] . '.' .
$ext;
@unlink($paper);
if (!move_uploaded_file($_FILES['SelectEditionFile']['tmp_name'], $paper))
// HERE PROBLEM
{
$_SESSION['Error'] = 'Cannot move uploaded file.'; }
...
Is Paper/ actually in the root directory of the PHP system tho?

Try an absolute file path.


.