Code:
function __construct(){
// $allowedExtensions = array_map("strtolower", $allowedExtensions);
// $this->allowedExtensions = $allowedExtensions;
// $this->sizeLimit = $sizeLimit;
$this->checkServerSettings();
if (isset($_GET['qqfile'])) {
$this->file = new qqUploadedFileXhr();
} elseif (isset($_FILES['qqfile'])) {
$this->file = new qqUploadedFileForm();
} else {
$this->file = false;
}
}
/**
* Initialize Preferences
*
* @access public
* @param array initialization parameters
* @return void
*/
public function initialize($params = array())
{
if (count($params) > 0)
{
foreach ($params as $key => $val)
{
if (isset($this->$key))
{
$this->$key = $val;
}
}
}
}
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Upload extends MY_Controller {
public function __construct()
{
parent::__construct();
}
public function do_upload()
{
$config = array();
$config['sizeLimit'] = 10 * 1024 * 1024;
$config['allowedExtensions'] = array();
$this->load->library('qqfileuploader');
$this->qqfileuploader->initialize($config);
$result = $this->qqfileuploader->handleUpload('/Applications/MAMP/htdocs/ci/cmx/res/uploads/');
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}
public function form()
{
$this->load->view('uploader_test/index');
}
}
/* End of file upload.php */
/* Location: ./application/controllers/Upload.php */
Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<?php echo site_url('res/css/fileuploader.css'); ?>" rel="stylesheet" type="text/css">
<style>
body {font-size:13px; font-family:arial, sans-serif; width:700px; margin:100px auto;}
</style>
</head>
<body>
<p><a href="http://github.com/valums/file-uploader">Back to project page</a></p>
<p>To upload a file, click on the button below. Drag-and-drop is supported in FF, Chrome.</p>
<p>Progress-bar is supported in FF3.6+, Chrome6+, Safari4+</p>
<div id="file-uploader-demo1">
<noscript>
<p>Please enable JavaScript to use file uploader.</p>
<!-- or put a simple form for upload here -->
</noscript>
</div>
[removed][removed]
[removed]
function createUploader(){
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: 'http://localhost:8888/ci/cmx/upload/do_upload/',
debug: true,
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif']
});
}
// in your app create uploader as soon as the DOM is ready
// don't wait for the window to load
window.onload = createUploader;
[removed]
</body>
</html>