Welcome Guest, Not a member yet? Register   Sign In
[Solved] Curious: $this->upload->display_errors();
#1

(This post was last modified: 04-04-2015, 01:17 PM by vrsotto.)

Hi

I'm able to do multiple uploads using the following codes (bellow). on $config (req. var in $this->process_file_upload($field_file_name$config)), i set allowed file types to "jpg|gif|png". So, when i test and upload files like in "file.htm, file.txt and then file.jpg". basically, files with ".htm" and ".txt" will not be uploaded. arrays $data[0]['error'] and arrays $data[2]['error'] should each have value "The filetype you are attempting to upload is not allowed." but what is happining is that arrays $data[2]['error'] kind'a concatenate value from $data[0]['error'], is this normal?  

Please see my attached file showing my dump result.

PHP Code:
for ($count 0$count $number_of_files$count++) { 
$this->load->library('upload'$config);

$_FILES[$field_file_name]['name'    $files['name'][$count];
$_FILES[$field_file_name]['type'    $files['type'][$count];
$_FILES[$field_file_name]['tmp_name'] = $files['tmp_name'][$count];
$_FILES[$field_file_name]['error'   $files['error'][$count];
$_FILES[$field_file_name]['size'    $files['size'][$count];

$data[] = $this->process_file_upload($field_file_name$config);
}

dump($data); // dump() is same as print_r(), a custom function

public function process_file_upload($field_file_name$config = array()) {
// Process Upload(s)
if ($this->upload->do_upload($field_file_name)) {
 
$data['upload'] = $this->upload->data();
} else {
 
$data['error'] = $this->upload->display_errors();
}
return 
$data;


Thanks,

vrsotto

Attached Files Thumbnail(s)
   
Reply
#2

(This post was last modified: 04-04-2015, 11:45 AM by gadelat.)

Yes. display_errors() outputs uploading errors for all of the files, doesn't matter if files were uploaded one by one. Remove this from loop
(04-04-2015, 10:11 AM)vrsotto Wrote:
PHP Code:
} else {
 
$data['error'] = $this->upload->display_errors();

and use that function after the loop
Reply
#3

Ah, Yes. Got the point! Thanks!

(04-04-2015, 11:44 AM)gadelat Wrote: Yes. display_errors() outputs uploading errors for all of the files, doesn't matter if files were uploaded one by one. Remove this from loop


(04-04-2015, 10:11 AM)vrsotto Wrote:
PHP Code:
} else {
 
$data['error'] = $this->upload->display_errors();

and use that function after the loop
Reply




Theme © iAndrew 2016 - Forum software by © MyBB