Welcome Guest, Not a member yet? Register   Sign In
File Upload Class File type problem
#1

[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
#2

[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
#3

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

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

[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.
#6

[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?




Theme © iAndrew 2016 - Forum software by © MyBB