move_uploaded_file on localhost

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • groupie

    #1

    move_uploaded_file on localhost

    Hi,
    The code below is working - it returns the 'Received' message, however
    I cannot find the uploaded file in the destination folder, or anywhere
    else (other than source directory). I'm running PHP 5.2.5 on my PC
    running Apache 2.0. Thanks.

    <?php
    $uploadDir = "/uploads";
    $temp = $uploadDir;

    if(is_uploaded_ file($_FILES['upfile']['tmp_name']))
    {
    }
    else
    {
    echo "the file was not uploaded correctly, try again";
    exit(0);
    }

    if(move_uploade d_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
    print "Received {$_FILES['upfile']['name']} - its size is
    {$_FILES['upfile']['size']}";
    else
    {
    echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
    $uploadDir";
    exit(0);
    }
    ?>
  • Piotr

    #2
    Re: move_uploaded_f ile on localhost

    groupie wrote:
    Hi,
    The code below is working - it returns the 'Received' message, however
    I cannot find the uploaded file in the destination folder, or anywhere
    else (other than source directory). I'm running PHP 5.2.5 on my PC
    running Apache 2.0. Thanks.
    >
    <?php
    $uploadDir = "/uploads";
    $temp = $uploadDir;
    >
    if(is_uploaded_ file($_FILES['upfile']['tmp_name']))
    {
    }
    else
    {
    echo "the file was not uploaded correctly, try again";
    exit(0);
    }
    >
    if(move_uploade d_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
    print "Received {$_FILES['upfile']['name']} - its size is
    {$_FILES['upfile']['size']}";
    else
    {
    echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
    $uploadDir";
    exit(0);
    }
    ?>
    You should find your file in your root directory, it will be named
    'uploads'.

    To solve your problem, you should add a filename to the destination
    part, like:
    move_uploaded_f ile($_FILES["upfile"]["tmp_name"],
    $uploadDir.$_FI LES["upfile"]["name"] );

    best regards
    Piotr Nastaly

    Comment

    • Piotr

      #3
      Re: move_uploaded_f ile on localhost

      Piotr wrote:
      groupie wrote:
      >Hi,
      >The code below is working - it returns the 'Received' message, however
      >I cannot find the uploaded file in the destination folder, or anywhere
      >else (other than source directory). I'm running PHP 5.2.5 on my PC
      >running Apache 2.0. Thanks.
      >>
      ><?php
      > $uploadDir = "/uploads";
      > $temp = $uploadDir;
      >>
      >if(is_uploaded _file($_FILES['upfile']['tmp_name']))
      >{
      >}
      >else
      >{
      > echo "the file was not uploaded correctly, try again";
      > exit(0);
      >}
      >>
      >if(move_upload ed_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
      > print "Received {$_FILES['upfile']['name']} - its size is
      >{$_FILES['upfile']['size']}";
      >else
      >{
      > echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
      >$uploadDir";
      > exit(0);
      >}
      >?>
      >
      You should find your file in your root directory, it will be named
      'uploads'.
      >
      To solve your problem, you should add a filename to the destination
      part, like:
      move_uploaded_f ile($_FILES["upfile"]["tmp_name"],
      $uploadDir.$_FI LES["upfile"]["name"] );
      >
      best regards
      Piotr Nastaly
      Ofc, i forgot to add directory separator
      move_uploaded_f ile($_FILES["upfile"]["tmp_name"],
      $uploadDir . DIRECTORY_SEPAR ATOR . $_FILES["upfile"]["name"] );

      Comment

      • groupie

        #4
        Re: move_uploaded_f ile on localhost

        On Apr 8, 9:38 pm, Piotr <s...@poczta.on et.plwrote:
        Piotr wrote:
        groupie wrote:
        Hi,
        The code below is working - it returns the 'Received' message, however
        I cannot find the uploaded file in the destination folder, or anywhere
        else (other than source directory). I'm running PHP 5.2.5 on my PC
        running Apache 2.0. Thanks.
        >
        <?php
          $uploadDir = "/uploads";
          $temp = $uploadDir;
        >
        if(is_uploaded_ file($_FILES['upfile']['tmp_name']))
        {
        }
        else
        {
           echo "the file was not uploaded correctly, try again";
           exit(0);
        }
        >
        if(move_uploade d_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
                print "Received {$_FILES['upfile']['name']} - its size is
        {$_FILES['upfile']['size']}";
        else
        {
           echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
        $uploadDir";
           exit(0);
        }
        ?>
        >
        You should find your file in your root directory, it will be named
        'uploads'.
        >
        To solve your problem, you should add a filename to the destination
        part, like:
        move_uploaded_f ile($_FILES["upfile"]["tmp_name"],
                           $uploadDir.$_FI LES["upfile"]["name"] );
        >
        best regards
        Piotr Nastaly
        >
        Ofc, i forgot to add directory separator
        move_uploaded_f ile($_FILES["upfile"]["tmp_name"],
                $uploadDir . DIRECTORY_SEPAR ATOR . $_FILES["upfile"]["name"] );- Hide quoted text -
        >
        - Show quoted text -
        Thank-you! It's working fine now.

        Comment

        Working...