discardthis
discardthis

Reputation: 179

PHP: Get filename (without extension) of uploaded file without knowing its path?

$_FILES['userfile']['name'] will return the extension. Is there a way to get just the name (no extension) besides using pathinfo()['filename']?

For context, I want to create a directory with mkdir based on a filename. Say you upload a zip file called bobby, I want to make a directory called bobby, not bobby.zip.

Upvotes: 0

Views: 1872

Answers (1)

Ramon J. A. Smit
Ramon J. A. Smit

Reputation: 341

This should do the trick:

echo basename(__FILE__, '.php');

edit My excuse, did not read it good.

pathinfo($filename, PATHINFO_FILENAME) 

should to the trick!

Upvotes: 4

Related Questions