[eluser]Unknown[/eluser]
[quote author="mi6crazyheart" date="1282340412"]From u'r description i really couldn't able to understand what's actually u want to ask. But, if u want to know how to get extension of the file which u want to upload then you can use this piece of codes...
Code:
$path_info = pathinfo($_FILES["userfile"]["name"]); // "userfile" is the form input field name
$fileExtension = $path_info[‘extension’];
[/quote]
Ok, I'll try to explain it better. There's a thread in this forum, the first one, called "CodeIgniter 1.7.2 Security Patch" which rewrites the upload.php library.
Before that patch, when uploading a file you needed to specify:
Code:
$config['allowed_types'] = 'gif|jpg|jpeg|png';
And you could specify
Code:
$config['file_name'] = 'some_name'
The last one let you override the original file name with 'some_name' while keeping the original extension of the file. E.g: the user uploads
and it is saved in the server as
Now, after the patch you must (at least I do in order for it to work) specify an extension in
Code:
$config['file_name'] = 'some_name.gif'
And that extension being in the
Code:
$config['allowed_types'] = 'gif|jpg|jpeg|png';
The problem with this is that it overrides the original file extension. E.g: user uploads
and it is saved in the server as
which is wrong.
If you don't specify an extension in
Code:
$config['file_name'] = 'some_name'
after the patch it will raise an error telling you that the file you're trying to upload its not a valid file, as I assume there's no 'blank' extension in the allowed types.
Thing is, I want to keep the original extension while using the file_name override.