CodeIgniter Forums
how do you know the extension of the browsed file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how do you know the extension of the browsed file (/showthread.php?tid=40635)



how do you know the extension of the browsed file - El Forum - 04-14-2011

[eluser]NEHIL[/eluser]
When you are uploading an image, you pass a config array. this is how mine looks like

Code:
$config = array(
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->gallery_path,
            'file_name' => '$filename'
        );
$this->load->library('upload',$config);
$this->upload->do_upload();

So know, knowing the fact that i have allowed so many types while giving the file_name i don't know what extension to put?
please help! :roll:


how do you know the extension of the browsed file - El Forum - 04-14-2011

[eluser]LuckyFella73[/eluser]
Hi NEHIL,

watch out for "$this->upload->data()" in the User-Guide:
http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html

It gives you an array with much info about the uploaded file.


how do you know the extension of the browsed file - El Forum - 04-14-2011

[eluser]NEHIL[/eluser]
doen't give info of the file after the upload is done? I need the seeting before the upload so that the filename can be saved


how do you know the extension of the browsed file - El Forum - 04-14-2011

[eluser]LuckyFella73[/eluser]
Quote:... while giving the file_name i don’t know what extension to put?

Take a few seconds to read the user guide like suggested then you know
how to get the file-extention of the uploaded file. I guess the filename
without the extention is not your problem.