CI_Upload::data PHP Method

data() public method

Returns an associative array containing all of the information related to the upload, allowing the developer easy access in one array.
public data ( string $index = NULL ) : mixed
$index string
return mixed
    public function data($index = NULL)
    {
        $data = array('file_name' => $this->file_name, 'file_type' => $this->file_type, 'file_path' => $this->upload_path, 'full_path' => $this->upload_path . $this->file_name, 'raw_name' => str_replace($this->file_ext, '', $this->file_name), 'orig_name' => $this->orig_name, 'client_name' => $this->client_name, 'file_ext' => $this->file_ext, 'file_size' => $this->file_size, 'is_image' => $this->is_image(), 'image_width' => $this->image_width, 'image_height' => $this->image_height, 'image_type' => $this->image_type, 'image_size_str' => $this->image_size_str);
        if (!empty($index)) {
            return isset($data[$index]) ? $data[$index] : NULL;
        }
        return $data;
    }

Usage Example

Example #1
0
 function do_upload($_FILES = '', $field = 'userfile')
 {
     if (empty($_FILES[$field])) {
         $this->set_error('upload_no_file_selected');
         return FALSE;
     } else {
         if (count($_FILES[$field]['name']) > 1) {
             foreach ($_FILES[$field]['name'] as $index => $name) {
                 if (!empty($name)) {
                     $this->do_xupload($_FILES, $field, $index);
                     $temp = parent::data();
                     $this->set_dataArray($temp, $index);
                 }
             }
             return true;
         } else {
             if ($field == 'proimg') {
                 $this->do_xupload($_FILES, $field);
                 $temp = parent::data();
                 $this->set_dataArray($temp, 0);
                 return true;
             } else {
                 parent::do_upload($_FILES, $field);
                 return parent::data();
             }
         }
     }
 }
All Usage Examples Of CI_Upload::data