Re: move_uploaded_file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You should be able to use either an absolute or relative path. In the code below, the path specified is absolute (it starts with /). If you want it to be relative to your current directory, change the line to:

$uploads_dir = 'uploads'; or $uploads_dir = '../uploads';

So basically, it all depends on how you define your path.

Joseph


Roberto wrote:
Am I just drunk or blind or the documentation is simply wrong?

>From the official doc
(http://uk2.php.net/manual/en/function.move-uploaded-file.php):

<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_FILES["pictures"]["name"][$key];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
?>

The path for the upload dir should be a relative one, not an absolute one.

Roberto Aloi
http://aloiroberto.wordpress.com
Twitter: @prof3ta


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux