[eluser]Diggory Laycock[/eluser]
Hello,
I was wondering if anyone could help me with an issue I'm having with CI's upload class.
I used it in a site last year without any issues. That site only allowed uploading of image files. I'm currently building a site which allows uploading QuickTime .mov files only.
Many files upload correctly, however the occasional file appears to confuse the upload class. It fails validation with the error "You did not select a file to upload" even though the user has.
I've tried spitting out $this->upload->data() and for these problem files it is empty except for the upload paths.
I've tried using Safari on Mac OS X and FireFox on Mac OS X. Both browsers cause the same behaviour in the CI app.
Here's a sample file that causes the issue (sorry it's 17mb):
[removed]
It's most puzzling - does anyone have any ideas?
[edit]
I've reproduced the issue in a test site:
[removed]
below is the code for the upload methods in the test site:
Code:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
$this->load->library('validation');
$this->load->helper('form');
$this->load->helper('number');
}
function index()
{
$data['error'] = '';
$data['uploadData'] = '';
$this->template->write_view('content', 'upload', $data, TRUE);
$this->template->render();
}
function processUpload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'mov';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$data = array('error' => $this->upload->display_errors('<p class="validationError">', '</p>'), 'uploadData' => $this->upload->data());
$this->template->write_view('content', 'upload', $data, TRUE);
$this->template->render();
}
else
{
$uploadMetadata = $this->upload->data();
$data = array(
'uploadData' => $uploadMetadata,
'uploadedFileSize' => byte_format($uploadMetadata['file_size'] * 1024) ,
);
$this->template->write_view('content', 'uploadComplete', $data, TRUE);
$this->template->render();
}
}
}