[eluser]java[/eluser]
Here is my code in processing file upload :
Controller:
Code:
class Ungxu extends Controller
{
function Ungxu()
{
parent::Controller();
$this->load->model('tintuc_model','tintuc');
$this->load->helper('form','url');
}
}
function index()
{
$this->load->view('ungxu', array('error' => ' ' ));// pass error argument
// attach file upload (if have)
if(isset($_POST['filename']))
{
$this->doUpload();
$this->email->attach('/uploads/folder/$file_name');
}
}
function doUpload()
{
$config['upload_path'] = '/uploads/ungxu/';
$config['allowed_types'] = 'doc|txt|rar';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$data['content'] = $this->load->view('dangky', $error, true);
}
else
{
$upload_data = $this->upload->data();
$filename = $upload_data['file_name'];
}
}
and view:
Code:
<tr>
<?=$error;?>
<?=form_open_multipart('ungxu/doUpload'); ?>
<td style="width: 198px">
Tài liệu đính kèm</td>
<td><input name="filename" type="file" id="filename" /> (Tối đa 1MB)</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" name="submit" value="Gửi" id="send" style="width:70px;"
<input type="reset" value="Làm lại" />
</td>
</tr>
</table>
</form>
My idea is if a visitor upload a file and webpages will automatically attach file to send mail. But when i try it, an error generated:
Quote:An Error Was Encountered
Unable to load the requested language file: language/upload_lang.php
My code have some problems? Please tell me how can resolve it? Thank you..