Wednesday, 14 August 2013

Blueimp Jquery upload plugin doesn't let the html code to be parsed in codeigniter

Blueimp Jquery upload plugin doesn't let the html code to be parsed in
codeigniter

I have been trying to use Blueimp jquery upload plugin in codeigniter.
Everything is fine, but there is a problem with parsing html code
I used the code of UploadHandler.php in a controller and also in a
library, but in both of them I face a problem that is confusing. The whole
code in the page reveals instead of being parsed. A piece of code is added
to the first line of HTML code and caused the problem:
{"files":[]}<!DOCTYPE html>
<html>
<head>
...
I think this {"files":[]} causes the problem, but I don't really know
where it comes from?!
here is the source code I'm using:
https://github.com/blueimp/jQuery-File-Upload
and this is the starting code of what i'm using in my controller:
class Gallery extends CI_Controller {
// --------------------------------------------------------------------
function __construct($options = null, $initialize = true, $error_messages
= null)
{
parent::__construct();
$this->load->model('admin/players_model');
$this->options = array(
'script_url' => $this->get_full_url().'/',
'upload_dir' =>
dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
'upload_url' => $this->get_full_url().'/files/',
'user_dirs' => false,
'mkdir_mode' => 0755,
'param_name' => 'files',
// Set the following option to 'POST', if your server does not
support
// DELETE requests. This is a parameter sent to the client:
'delete_type' => 'DELETE',
'access_control_allow_origin' => '*',
'access_control_allow_credentials' => false,
'access_control_allow_methods' => array(
'OPTIONS',
'HEAD',
'GET',
'POST',
'PUT',
'PATCH',
'DELETE'
),
'access_control_allow_headers' => array(
'Content-Type',
'Content-Range',
'Content-Disposition'
),
// Enable to provide file downloads via GET requests to the PHP
script:
// 1. Set to 1 to download files via readfile method through PHP
// 2. Set to 2 to send a X-Sendfile header for lighttpd/Apache
// 3. Set to 3 to send a X-Accel-Redirect header for nginx
// If set to 2 or 3, adjust the upload_url option to the base path of
// the redirect parameter, e.g. '/files/'.
'download_via_php' => false,
// Read files in chunks to avoid memory limits when download_via_php
// is enabled, set to 0 to disable chunked reading of files:
'readfile_chunk_size' => 10 * 1024 * 1024, // 10 MiB
// Defines which files can be displayed inline when downloaded:
'inline_file_types' => '/\.(gif|jpe?g|png)$/i',
// Defines which files (based on their names) are accepted for
upload:
'accept_file_types' => '/.+$/i',
// The php.ini settings upload_max_filesize and post_max_size
// take precedence over the following max_file_size setting:
'max_file_size' => null,
'min_file_size' => 1,
// The maximum number of files for the upload directory:
'max_number_of_files' => null,
// Image resolution restrictions:
'max_width' => null,
'max_height' => null,
'min_width' => 1,
'min_height' => 1,
// Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true,
// Set to false to disable rotating images based on EXIF meta data:
'orient_image' => true,
'image_versions' => array(
// Uncomment the following version to restrict the size of
// uploaded images:
/*
'' => array(
'max_width' => 1920,
'max_height' => 1200,
'jpeg_quality' => 95
),
*/
// Uncomment the following to create medium sized images:
/*
'medium' => array(
'max_width' => 800,
'max_height' => 600,
'jpeg_quality' => 80
),
*/
'thumbnail' => array(
// Uncomment the following to use a defined directory for
the thumbnails
// instead of a subdirectory based on the version identifier.
// Make sure that this directory doesn't allow execution
of files if you
// don't pose any restrictions on the type of uploaded
files, e.g. by
// copying the .htaccess file from the files directory for
Apache:
//'upload_dir' =>
dirname($this->get_server_var('SCRIPT_FILENAME')).'/thumb/',
//'upload_url' => $this->get_full_url().'/thumb/',
// Uncomment the following to force the max
// dimensions and e.g. create square thumbnails:
//'crop' => true,
'max_width' => 80,
'max_height' => 80
)
)
);
if ($options) {
$this->options = array_merge($this->options, $options);
}
if ($error_messages) {
$this->error_messages = array_merge($this->error_messages,
$error_messages);
}
if ($initialize) {
$this->initialize();
}
}
How should I make it work?!

No comments:

Post a Comment