CodeIgniter Forums
File Upload Class File type problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: File Upload Class File type problem (/thread-27269.html)



File Upload Class File type problem - El Forum - 02-05-2010

[eluser]RJ[/eluser]
Hello,

I'm trying to allow .log files to be uploaded but when specified it doesnt seem to matter, the same error appears "filetype you are attempting to upload is not allowed"
Code:
$config['allowed_types'] = 'txt|log';

any help is much appreciated


File Upload Class File type problem - El Forum - 02-05-2010

[eluser]RJ[/eluser]
I tried changing the file name before initilizing the upload class like this:
Code:
$tmp = substr($_FILES['userfile']['name'], 0,(strpos($_FILES['userfile']['name'],'.')+1));
$_FILES['userfile']['name'] = $tmp . 'txt';

But doesn't work, must be something in the temp name, any thoughts how I can fix this? If I change the files to .txt they upload fine, when they're .log it errors out every time.

Thanks


File Upload Class File type problem - El Forum - 02-08-2010

[eluser]RJ[/eluser]
no one has any ideas?


File Upload Class File type problem - El Forum - 02-08-2010

[eluser]danmontgomery[/eluser]
In $this->upload->data(), file_type should be either 'text/plain' or 'text/x-log' (case sensitive), what is it?


File Upload Class File type problem - El Forum - 02-08-2010

[eluser]RJ[/eluser]
Quote:Array
(
[file_name] =>
[file_type] =>
[file_path] => ./uploads/
[full_path] => ./uploads/
[raw_name] =>
[orig_name] =>
[file_ext] =>
[file_size] =>
[is_image] =>
[image_width] =>
[image_height] =>
[image_type] =>
[image_size_str] =>
)
application/octet-stream

Application?
Code:
$config['allowed_types'] = 'txt|log';

A sample of the log file being uploaded is attached... i change from .log to .txt works great, but something isn't working right with .log; I had to zip the file, CI wont let me upload .log to the forum.


File Upload Class File type problem - El Forum - 02-08-2010

[eluser]RJ[/eluser]
Figured it out, for some reason the
Code:
$_FILES['userfile']['type']
for .log files is application. I manually change the type to text/plain before initializing the uploads library and works fine.

a bug?