0

My CodeIgniter version is 3.1.2.

Autoload.php -> nothing added to autoload. When trying to upload I am getting HTTP 500.

Can anybody suggest a solution?

public function UploadProfileimage() {
        try {
            $this->load->helper(array('form', 'url'));
            $this->load->library('upload');

            $profileimagefolder = 'C:' . DIRECTORY_SEPARATOR . 'xampp' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'jalpp';
            if (!is_dir($profileimagefolder)) {
                mkdir($profileimagefolder, 0777, TRUE);
            }
            $config['upload_path'] = $profileimagefolder . DIRECTORY_SEPARATOR;
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = 100;
            $config['max_width'] = 1024;
            $config['max_height'] = 768;


            $this->upload->initialize($config);
            if (!$this->upload->do_upload('profileimage')) {
                printv($this->upload->display_errors());
            } else {
                $data = array('upload_data' => $this->upload->data());
                $this->load->view('upload_success', $data);
            }
        } catch (Exception $e) {
            //printv($e);
            echo ($e->getMessage());
        }
    }

output:

enter image description here

5
  • This error is occurs because when you click for upload when execution of code comes in this function there is a syntax error or there is not properly closed bracket in this function so localhost gives 500 error. Commented Dec 11, 2016 at 8:38
  • 1
    With any error message, 500 Internal Server Error, you will first want to check any Apache and PHP error logs for your server. These logs can provide valuable context related to any code failures or other potential causes of a site failure. Commented Dec 11, 2016 at 8:38
  • i have fully check, syntax error on this code.: $this->upload->initialize($config); and $this->load->library('upload'); not working properly Commented Dec 11, 2016 at 9:02
  • you have to replace all libraries with 2.2.6 libraries..becoz there is issue in 3.1.2. Commented Dec 12, 2016 at 6:17
  • Possible duplicate of CodeIgniter upload fail no error logs no error reporting Commented Dec 12, 2016 at 13:50

2 Answers 2

1

i fixed this by using by 2.2 CI version's Upload library and mime type in 3.1.2 now it is working fine.

Thank you for your response

Sign up to request clarification or add additional context in comments.

Comments

0

This is typically an indication of a syntax error in your PHP somewhere. Your PHP error log will have an entry pointing you to the file and line number of the error.

If I were to speculate on the cause, I would guess its your printv() function call. printv() is not a native PHP function, so unless you have defined it somewhere else, that is likely the cause.

1 Comment

printv is my custom function to print on test mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.