CodeIgniter Forums
I think the code is correct. But......... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: I think the code is correct. But......... (/thread-1733.html)



I think the code is correct. But......... - El Forum - 06-22-2007

[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>
&lt;?=$error;?&gt;
    &lt;?=form_open_multipart('ungxu/doUpload'); ?&gt;

      <td style="width: 198px">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Tài liệu đính kèm</td>
      <td>&lt;input name="filename" type="file" id="filename" /&gt; (Tối đa 1MB)</td>
</tr>
<tr>
    <td align="center" colspan="2">
     &lt;input type="submit" name="submit" value="Gửi" id="send" style="width:70px;"
&lt;input type="reset" value="Làm lại" /&gt;                            
    </td&gt;
</tr>
   </table>                
  &lt;/form&gt;
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..


I think the code is correct. But......... - El Forum - 06-23-2007

[eluser]Crimp[/eluser]
It looks like a file is missing in your CI system's language folder: upload_language.php. It's part of the core and contains the messages used for file upload. Look in the system/language folder and see if the file is there. You may have erased it by accident.