note 54767 deleted from function.basename by cmb

From: Date: Fri, 14 Oct 2016 17:32:13 +0000
Subject: note 54767 deleted from function.basename by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206899@lists.php.net to get a copy of this message
Note Submitter: pvollma at pcvsoftware dot net ---- Note that in my example below, I used the stripslashes function on the target string first because I was dealing with the POST array $_FILES. When creating this array, PHP will add slashes to any slashes it finds in the string, so these must be stripped out first before processing the file path. Then again, the only reason I can think of that basename() would fail is when dealing with Windows paths on a *nix server -- and the file upload via POST is the only situation I can think of that would require this. Obviously, if you are not dealing with these additional slashes, invoking stripslashes() first would remove the very separators you need extract the file name from the full path.

« previous php.notes (#206899) next »