[eluser]murphybr[/eluser]
I am trying to understand and use a basic widget from the examples Custom Upload
(using CI 2.x)
I have pasted my View:
Code:
Javascript paths for the following(plupload.full.js, jquery-1.6.1.min.js,jquery.plupload.queu.js)
<div id="container">
<div id="filelist"></div>
<br />
<a id="pickfiles" href="#">[Select files]</a>
<a id="uploadfiles" href="#">[Upload files]</a>
</div>
<s.c.r.i.p.t t.y.p.e="t.e.x.t./.j.a.v.a.s.c.r.i.p.t">
// Convert divs to queue widgets when the DOM is ready
$(function() {
// Setup html5 version
$("#html5_uploader").pluploadQueue({
// General settings
runtimes : 'html5',
url : 'FilesTransfer.php/do_upload',
max_file_size : '2048mb',
chunk_size : '100mb',
unique_names : true,
});
// Setup html4 version
$("#html4_uploader").pluploadQueue({
// General settings
runtimes : 'html4',
url : 'FilesTransfer.php/do_upload'
});
var uploader = new plupload.Uploader({
runtimes : 'gears,html5,flash,silverlight,browserplus',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '10mb',
url : 'FileTransfer.php/do_upload',
});
uploader.bind('Init', function(up, params) {
$('#filelist').html("<div>Current runtime: " + params.runtime + "</div>");
});
$('#uploadfiles').click(function(e) {
uploader.start();
e.preventDefault();
});
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
$.each(files, function(i, file) {
$('#filelist').append(
'<div id="' + file.id + '">' +
file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
'</div>');
});
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('UploadProgress', function(up, file) {
$('#' + file.id + " b").html(file.percent + "%");
});
uploader.bind('Error', function(up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('FileUploaded', function(up, file) {
$('#' + file.id + " b").html("100%");
});
});
</.s.c.r.i.p.t>
</body>
my Controller is as follows:
Code:
function do_upload()
{
ini_set('upload_max_filesize', '2000M');
ini_set('post_max_size', '2000M');
ini_set('max_input_time', 900);
ini_set('max_execution_time', 900);
$user = $_SESSION['userName'];
$DS = DIRECTORY_SEPARATOR;
$this->user_upload_path = APPPATH.'../../upload'.$DS.$_SESSION['profilepath'].$DS.$this->userFolder.$DS;
$config['upload_path'] = $this->user_upload_path;
$config['allowed_types'] = '*';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$data['title'] = "Transfer Upload";
$data['heading'] = "File Transfer";
$data['subHeading'] = "Upload Page";
$error = array();
$this->load->library('upload', $config);
$this->header(1,$data);
if ($_SESSION['profilepath'] != NULL)
{
if (!is_dir($this->user_upload_path))
{
mkdir($this->user_upload_path);
}
$data = array('upload_data' => $this->upload->data());
if ((! $this->upload->do_upload()) && ($data['upload_data']['file_name'] != NULL))
{
$data = array('upload_data' => $this->upload->data());
$file = $data['upload_data']['file_name']; // file name for logging
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_fail', $error);
}
if ((! $this->upload->do_upload()) && ($data['upload_data']['file_name'] == NULL))
{
$data = array('upload_data' => $this->upload->data());
$file = $data['upload_data']['file_name']; // file name for logging
$this->load->view('upload');
}
else
{
$data = array('upload_data' => $this->upload->data());
$file = $data['upload_data']['file_name']; // file name for logging
$message = $user.' uploaded file '.$file .' to the upload share.';
$this->load->view('upload_success', $data);
}
$this->footer();
}
else {
$this->load->view('noProfilePath');
$this->footer();
}
}
could someone help direct me on what I am doing wrong.
my view (in Firefox)shows that the current runtime is:html5 then shows the 2 links (select file) and (upload file)
select file shows the file selected under the current runtime display.
but when i click upload file i get the following error:
Quote:Current runtime: html5
empty file.txt (1 b)
Error: -200, Message: HTTP Error., File: empty file.txt
Also if i try to upload a file that is 1GB, i get the -600 error.
on IE, the Select File and Upload File links dont work at all.
With IE, is there anyway to get chunking to work for plupload while using CI?