Jump to content

pathinfo


sgt_fireman

Recommended Posts

Hey guys, so I was trying to create something that very simply gets the file extension for me, however for some reason the output of $xnt is the first letter of the uploaded file, and not the extension, Any Ideas anyone? Thank-you very much in advance.

 

$path2 = $_FILES['uploadedfile']['name'];
$xnt = ($path2['extension']);
echo $xnt;
die();

Link to comment
https://forums.phpfreaks.com/topic/266877-pathinfo/
Share on other sites

@sgt_fireman, you have to consider your decisions working with files and uploading them to the server and database.

@BuildMyWeb, strrchr is a pretty tricky function (I've never used it), but.... what about this ? It's a real file extension ?

$str = 'file_test. php';
$file_ext = substr( strrchr($str, '.') ,true);
var_dump($file_ext); 

Link to comment
https://forums.phpfreaks.com/topic/266877-pathinfo/#findComment-1368217
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.