Welcome Guest, Not a member yet? Register   Sign In
Array ( [error] => You did not select a file to upload. )
#1

[eluser]behnampmdg3[/eluser]
Hello;

Trying ti upload a csv but I get this error.

Any ideas?

Thank you.

Code:
<?php
                      $attributes = array('name' => 'upload_csv', 'id' => 'upload_csv');
                      echo form_open_multipart('upload_csv/check/'.$id, $attributes);
                      $file_data = array('name'  => 'file');
                      echo form_upload($file_data);
                      $submit_data = array('name'  => 'submit', 'value' =>'Upload');
                      echo form_submit($submit_data);
                ?>
Code:
if($_POST)
    {
     print_r($_POST);
     print_r($_FILES);
    /*prints: Array ( [submit] => Upload ) Array ( [file] => Array ( [name] => template_379.csv [type] => text/csv [tmp_name] => /tmp/phpo7I5JX [error] => 0 [size] => 35 ) ) */
     $config['upload_path'] = '/uploads/';
     $config['allowed_types'] = 'csv';
     $config['max_size'] = '100';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload($file))
      {
       $data['error'] = array('error' => $this->upload->display_errors());
      }
     else
      {
       $data = array('upload_data' => $this->upload->data());
      }
    }
#2

[eluser]CroNiX[/eluser]
Where is $file defined?
Code:
if (!$this->upload->do_upload($file))
#3

[eluser]behnampmdg3[/eluser]
Code:
print_r($_POST);
     print_r($_FILES);
     echo "<hr />";
     echo "File";
     echo $file = $_FILES['file']['tmp_name'];
     echo "<hr />";
     $config['upload_path'] = 'csv_files';
     $config['allowed_types'] = 'csv';
     $config['max_size'] = '100';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload('file'))
      {
       $data['error'] = array('error' => $this->upload->display_errors());
      }
     else
      {
       $data = array('upload_data' => $this->upload->data());
      }
     print_r($data['error']);


Quote:Array ( [submit] => Upload ) Array ( [file] => Array ( [name] => template_380.csv [type] => text/csv [tmp_name] => /tmp/php4byYly [error] => 0 [size] => 54 ) ) File/tmp/php4byYlyArray ( [error] =>

The filetype you are attempting to upload is not allowed.
)



So I added 'text/plain' to mime_types and it works.

Now my next step is to insert these values into the database. What is the best way Cronix?

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB