input->get('qqfile')) { $file = $this->input->get('qqfile'); } else if ($_FILES['qqfile']) { $file = $_FILES['qqfile']['tmp_name']; } if ($this->security->xss_clean($file)) { $ext = pathinfo($file, PATHINFO_EXTENSION); $extensions = array('png', 'jpeg', 'jpg', 'gif', 'bmp'); // Acceptable file extensions if (in_array($ext, $extensions)) { $directory = './uploads/'; if ($this->input->get('qqfile')) { $input = fopen('php://input', 'r'); $temp = tmpfile(); $realSize = stream_copy_to_stream($input, $temp); fclose($input); $target = fopen($directory . $filename, 'w'); fseek($temp, 0, SEEK_SET); stream_copy_to_stream($temp, $target); fclose($target); } else if ($_FILES['qqfile']) { move_uploaded_file($_FILES['qqfile']['tmp_name'], $directory . $filename.'.'.$ext); } $this->output->set_output(json_encode(array('success' => 'true', 'filename' => $file))); } else { $this->output->set_output(json_encode(array('error' => 'File type not supported.'))); } } ?>