Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.