Please tell me, I can not get the extension of the file being downloaded.

<?php $uploaddir = '/home/aasinua/crm.contrust.club/uploads/'; $ext = pathinfo($uploaddir, PATHINFO_EXTENSION); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . 'название' . $ext)) { print "File is valid, and was successfully uploaded."; } else { print "There some errors!"; } ?> 

What is the problem?

    2 answers 2

    What is the problem?

    The problem is that you are trying to get the extension not from the file, but from the /home/aasinua/crm.contrust.club/uploads/ directory

     $uploaddir = '/home/aasinua/crm.contrust.club/uploads/'; $ext = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . 'название.' . $ext)) { print "File is valid, and was successfully uploaded."; } else { print "There some errors!"; } 

    Info: Download files using the POST method

       $ext = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION);