According to the POST method uploads section of the PHP Manual, $_FILES['userfile']['name']
is the original name of the file on the client machine. Example #2 in that section uses the basename
function with $_FILES['userfile']['name']
like the following:
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
I did some experiments on my local host (Apache 2.2.14, PHP 5.3.1, Windows XP) and found out that the following two lines are equivalent:
$_FILES['userFile']['name']; // "file.txt"
basename($_FILES['userFile']['name']); // "file.txt"
That is, using the basename
function with $_FILES['userFile']['name']
seems rather redundant. Isn't it?