[eluser]harly[/eluser]
code controller/Upload.php
<?php
class Upload extends Controller {
function Upload() {
parent::Controller();
// $this->load->helper('form');
}
function index() {
$this->load->view('upload_form');
}
function doUpload() {
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1920';
$config['max_height'] = '1280';
$this->load->library('upload', $config);
if(!$this->upload->do_upload()) echo $this->upload->display_errors();
else {
$fInfo = $this->upload->data();
$this->_createThumbnail($fInfo['file_name']);
$data['uploadInfo'] = $fInfo;
$data['thumbnail_name'] = $fInfo['raw_name'] . '_thumb' . $fInfo['file_ext'];
$this->load->view('upload_success', $data);
}
}
function _createThumbnail($fileName) {
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/' . $fileName;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 75;
$this->load->library('image_lib', $config);
if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();
}
}
code view/upload_form
<div id="container">
<h2>Upload an Image </h2>
<?php echo form_open_multipart('upload/doUpload'); ?>
<input type="file" name="userfile" />
<p><input type="submit" value="Submit" name="submit" /></p>
<?php echo form_close(); ?>
</div>
yesterday i'm try download code tutorial in website. upload image and crop.
i running code in pc windows no problem but my code running in server linux problem.
ERROR:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Upload::$upload
Filename: controllers/upload.php
Line Number: 25
Fatal error: Call to a member function do_upload() on a non-object in /hermes/bosweb/web122/b1228/sl.????/public_html/imageupload/application/controllers/upload.php on line 25