Welcome Guest, Not a member yet? Register   Sign In
how cat get the file extension?

hi, how i can get the file extension before upload the file? i need know for put the correct path..

img_principal is the input type file in the view...

$config['file_1']['upload_path']     = './uploads/logos/';
            $config['file_1']['allowed_types']  = 'gif|jpg|png';
            $config['file_1']['encrypt_name']     = true;
        !!!!!! here !!!! how can? if(['img_principal']['file_ext']=='swf' ){
            $config['file_2']['upload_path']     = './uploads/medios/swf';
            $config['file_2']['allowed_types']  = 'swf|fla';
            $config['file_2']['encrypt_name']     = true;
            $config['file_2']['upload_path']     = './uploads/medios/img';
            $config['file_2']['allowed_types']  = 'gif|jpg|png';
            $config['file_2']['encrypt_name']     = true;

ok problem solved.. if any have the same dude...

$nombre = $_FILES['img_principal']['name'];
$partes = explode(".", $nombre);
$ext = end($partes);

You can't access it before the upload - how would the server know what type of file it was if it wasn't uploaded to it first?!


Bottom of that page shows you how to access it after the upload.

thaks.. but i solved the problem whit the code before init the upload... whit this i can know the file extesion and make variable the config path, for multiple uploas files.. xd

$nombre = $_FILES[‘img_principal’][‘name’];
      $partes = explode(”.”, $nombre);
      $ext = end($partes);

There is a function build in PHP5.

$nombre = pathinfo($_FILES['img_principal']['name']);
echo $nombre['extension'];

This givs you the file extension, to!

Theme © iAndrew 2016 - Forum software by © MyBB