Re: move_uploaded_file on localhost



On Apr 8, 9:38 pm, Piotr <s...@xxxxxxxxxxxxxx> wrote:
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_uploaded_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_file($_FILES["upfile"]["tmp_name"],
                   $uploadDir.$_FILES["upfile"]["name"] );

best regards
Piotr Nastaly

Ofc, i forgot to add directory separator
move_uploaded_file($_FILES["upfile"]["tmp_name"],
        $uploadDir . DIRECTORY_SEPARATOR . $_FILES["upfile"]["name"] );- Hide quoted text -

- Show quoted text -

Thank-you! It's working fine now.
.



Relevant Pages

  • Re: move_uploaded_file on localhost
    ... I cannot find the uploaded file in the destination folder, ... else (other than source directory). ... I'm running PHP 5.2.5 on my PC ...
    (comp.lang.php)
  • Re: move_uploaded_file on localhost
    ... Piotr wrote: ... I cannot find the uploaded file in the destination folder, ... I'm running PHP 5.2.5 on my PC ...
    (comp.lang.php)
  • move_uploaded_file on localhost
    ... I cannot find the uploaded file in the destination folder, ... I'm running PHP 5.2.5 on my PC ... echo "the file was not uploaded correctly, ...
    (comp.lang.php)