note 52954 added to function.move-uploaded-file
| From: | Darrell at osu1 dot php dot net | Date: | Wed, 18 May 2005 21:51:10 +0000 |
| Subject: | note 52954 added to function.move-uploaded-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89602@lists.php.net to get a copy of this message | ||
move_uploaded_file apparently uses the root of the Apache installation (e.g. "Apache
Group\Apache2" under Windows) as the upload location if relative pathnames are used.
For example,
$ftmp = $_FILES['userfile']['tmp_name'];
$fname = $_FILES['userfile']['name'];
move_uploaded_file($ftmp, $fname);
moves the file to
"Apache Group\Apache2\$fname";
In contrast, other file/directory related functions use the current directory of the php script as
the offset for relative pathnames. So, for example, if the command
mkdir('tmp');
is called from 'Apache Group\Apache2\htdocs\testpages\upload.php', the result is to create
'Apache Group\Apache2\htdocs\testpages\tmp'
On the other hand, if 'mkdir' is called just before 'move_uploaded_file', the
behavior changes. The commands,
mkdir('tmp');
move_uploaded_file($ftmp, $fname);
used together result in
"Apache Group\Apache2\htdocs\testpages\tmp\$fname"
being created. Wonder if this is a bug or a feature.
Darrell
----
Manual Page -- http://www.php.net/manual/en/function.move-uploaded-file.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52954
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52954&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52954&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52954&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52954&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52954&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52954&report=yes
Search -- http://master.php.net/manage/user-notes.php