Welcome Guest, Not a member yet? Register   Sign In
I can't Upload File
#4

[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>

&lt;?php echo form_open_multipart('upload/doUpload'); ?&gt;
&lt;input type="file" name="userfile" /&gt;
<p>&lt;input type="submit" value="Submit" name="submit" /&gt;&lt;/p>
&lt;?php echo form_close(); ?&gt;
</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


Messages In This Thread
I can't Upload File - by El Forum - 11-18-2009, 10:00 AM
I can't Upload File - by El Forum - 11-18-2009, 10:22 AM
I can't Upload File - by El Forum - 11-24-2009, 06:39 PM
I can't Upload File - by El Forum - 11-25-2009, 02:32 AM
I can't Upload File - by El Forum - 11-25-2009, 06:23 AM
I can't Upload File - by El Forum - 11-25-2009, 11:58 AM
I can't Upload File - by El Forum - 11-25-2009, 12:53 PM
I can't Upload File - by El Forum - 11-25-2009, 01:24 PM
I can't Upload File - by El Forum - 11-25-2009, 01:25 PM
I can't Upload File - by El Forum - 11-26-2009, 12:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB