Connecting Tech Pros Worldwide Help | Site Map

move_uploaded_file returns false

  #1  
Old March 13th, 2008, 07:55 PM
R.A.M.
Guest
 
Posts: n/a
Hello,
Please help in the following problem:
I have written a PHP5 script uploading file:

if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
isset($_POST['EditionFile']) && isset($_POST['Year']) &&
isset($_POST['Month']))
{
if (is_uploaded_file($_FILES['SelectEditionFile']['tmp_name']))
{
// Load file:
$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))
{
$_SESSION['Error'] = 'Cannot move file.';
}
....

The problem is that 'Cannot move file' is reached during execution of the
script. I don't know why. I have checked priviledges on $paper folder: it
looks OK.
Will you help me?
/RAM/
  #2  
Old March 13th, 2008, 08:45 PM
Rik Wasmus
Guest
 
Posts: n/a

re: move_uploaded_file returns false


On Thu, 13 Mar 2008 20:48:32 +0100, R.A.M. <r_ahimsa_m@poczta.onet.pl
wrote:
Quote:
Hello,
Please help in the following problem:
I have written a PHP5 script uploading file:
>
if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
isset($_POST['EditionFile']) && isset($_POST['Year']) &&
isset($_POST['Month']))
{
if (is_uploaded_file($_FILES['SelectEditionFile']['tmp_name']))
{
// Load file:
$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))
{
$_SESSION['Error'] = 'Cannot move file.';
}
...
>
The problem is that 'Cannot move file' is reached during execution of the
script. I don't know why. I have checked priviledges on $paper folder:it
looks OK.

What are the priviledges, and what does realpath($paper); tell you about
the directory?
--
Rik Wasmus
  #3  
Old March 17th, 2008, 01:35 PM
R.A.M.
Guest
 
Posts: n/a

re: move_uploaded_file returns false


Rik Wasmus wrote:
Quote:
What are the priviledges, and what does realpath($paper); tell you about
the directory?
The priviledges are rwxrwxr-x.
echo realpath($paper) prints nothing, so $papaer is null or empty, I think.
The problem was not occuring so far.
/RAM/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
is_file() returns false for uploaded files? Kimmo Laine answers 6 April 20th, 2006 01:05 PM
Photo Upload - Wont work on Linux Server matt answers 10 July 17th, 2005 12:47 PM
Help debugging Flat File Picture Gallery matt answers 2 July 17th, 2005 11:41 AM
is_uploaded_file() help needed Ralph Freshour answers 2 July 17th, 2005 01:28 AM