is_uploaded_file() is TRUE but move_uploaded_file() fails - why?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • comp.lang.php

    #1

    is_uploaded_file() is TRUE but move_uploaded_file() fails - why?

    Consider my code:

    [PHP]
    if ($this->isSuccessful &&
    is_file($_FILES['uploaded_resum e_path']['tmp_name'])) { //
    STEP 6: MOVE RESUME TO DIRECTORY
    $uuid = $this->sfug->getUUID();
    if (!$uuid) $this->sfug->setUUID();
    $uuid = $this->sfug->getUUID();

    print_r(is_uplo aded_file($_FIL ES['uploaded_resum e_path']['tmp_name']));
    error_reporting (E_ALL);
    move_uploaded_f ile($_FILES['uploaded_resum e_path']['tmp_name'],
    actual_path("$r esumeBasePath/$uuid/" .
    $_FILES['uploaded_resum e_path']['name'])); // realpath() FAILS UNLESS
    FILE EXISTS
    if (!is_file(actua l_path("$resume BasePath/$uuid/" .
    $_FILES['uploaded_resum e_path']['name']))) {
    list($moveKomma nd, $moveRedirect) =
    @array_values($ this->getKommandOSAr ray('move'));
    $msg = exec("$moveKomm and \"" .
    $_FILES['uploaded_resum e_path']['tmp_name'] . '" "' .
    actual_path("$r esumeBasePath/$uuid/" .
    $_FILES['uploaded_resum e_path']['name']) . "\" $moveRedirect") ;
    if ($msg || !is_file(actual _path("$resumeB asePath/$uuid/" .
    $_FILES['uploaded_resum e_path']['name']))) {
    $this->isSuccessful = false;
    $this->setErrorArray( array('uploaded _resume_path' => 'Was unable
    to store uploaded resume: ' . nl2br($msg)));
    }
    }
    }
    error_reporting (E_ALL && ~E_NOTICE);
    [/PHP]

    Upon testing I found that is_uploaded_fil e() is set to TRUE, but
    move_uploaded_f ile() fails, no errors, no warnings, nothing, it just
    completely fails to move the file, even though it is proven to not only
    exist but is findable.

    What could cause something like that to occur?

    Thanx
    Phil

  • Chung Leong

    #2
    Re: is_uploaded_fil e() is TRUE but move_uploaded_f ile() fails - why?

    comp.lang.php wrote:[color=blue]
    > Consider my code:
    >
    > [PHP]
    > if ($this->isSuccessful &&
    > is_file($_FILES['uploaded_resum e_path']['tmp_name'])) { //
    > STEP 6: MOVE RESUME TO DIRECTORY
    > $uuid = $this->sfug->getUUID();
    > if (!$uuid) $this->sfug->setUUID();
    > $uuid = $this->sfug->getUUID();
    >
    > print_r(is_uplo aded_file($_FIL ES['uploaded_resum e_path']['tmp_name']));
    > error_reporting (E_ALL);
    > move_uploaded_f ile($_FILES['uploaded_resum e_path']['tmp_name'],
    > actual_path("$r esumeBasePath/$uuid/" .
    > $_FILES['uploaded_resum e_path']['name'])); // realpath() FAILS UNLESS
    > FILE EXISTS
    > if (!is_file(actua l_path("$resume BasePath/$uuid/" .
    > $_FILES['uploaded_resum e_path']['name']))) {
    > list($moveKomma nd, $moveRedirect) =
    > @array_values($ this->getKommandOSAr ray('move'));
    > $msg = exec("$moveKomm and \"" .
    > $_FILES['uploaded_resum e_path']['tmp_name'] . '" "' .
    > actual_path("$r esumeBasePath/$uuid/" .
    > $_FILES['uploaded_resum e_path']['name']) . "\" $moveRedirect") ;
    > if ($msg || !is_file(actual _path("$resumeB asePath/$uuid/" .
    > $_FILES['uploaded_resum e_path']['name']))) {
    > $this->isSuccessful = false;
    > $this->setErrorArray( array('uploaded _resume_path' => 'Was unable
    > to store uploaded resume: ' . nl2br($msg)));
    > }
    > }
    > }
    > error_reporting (E_ALL && ~E_NOTICE);
    > [/PHP]
    >
    > Upon testing I found that is_uploaded_fil e() is set to TRUE, but
    > move_uploaded_f ile() fails, no errors, no warnings, nothing, it just
    > completely fails to move the file, even though it is proven to not only
    > exist but is findable.
    >
    > What could cause something like that to occur?
    >
    > Thanx
    > Phil[/color]

    Are you running in safe-mode or using open_basedir? If restrictions
    imposed by either of these is preventing the move, move_uploaded_f ile()
    would fails without emitting an error.

    Comment

    Working...