Re: move_uploaded_file

From: Date: Fri, 11 Dec 2009 18:20:33 +0000
Subject: Re: move_uploaded_file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-300389@lists.php.net to get a copy of this message
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


« previous php.general (#300389) next »