• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Uploading a .php file via do_upload

#1
[eluser]popovich[/eluser]
Hi,

I am trying to upload a .php file using the upload class.
Here is a part of the code
Code:
if( isset($_FILES['layoutfile']) ){
                    $config['upload_path'] = './system/application/views/layouts/';
                    $config['allowed_types'] = 'php|application/octet-stream';
                    $config['overwrite'] = true;
                    $this->upload->initialize($config);
    
                    if ( ! $this->upload->do_upload('layoutfile') ){
                        print_r($_FILES['layoutfile']['type']);
                        exit($this->upload->display_errors());
                    } else {
                        $layfiledata = $this->upload->data();
                        $filepath = "layout_filepath = '".$layfiledata['file_name']."',";
                    }
                }

Nothing before this piece of code or after it does anything to $_FILES array.
The screen I get looks like this:
Code:
application/octet-stream
The filetype you are attempting to upload is not allowed.

Apparently, the upload class cannot upload the file because of its mime-type?
The form in the view file has
Code:
enctype="multipart/form-data"
in it.

Where is the trouble?...

#2
[eluser]popovich[/eluser]
No ideas?

#3
[eluser]popovich[/eluser]
I got it.

system/application/config/mimes.php

change the line
Code:
'php'    =>    'application/x-httpd-php',

to
Code:
'php'    =>    array('application/x-httpd-php','application/octet-stream'),

#4
[eluser]bryantAXS[/eluser]
thanks for posting your solution, i feel like i might need this at some point Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.