Welcome Guest, Not a member yet? Register   Sign In
File Upload error
#1

[eluser]hrg.vincent[/eluser]
Controller
Code:
$this->showHead();

$config['upload_path'] = './upload/';  
$config['allowed_types'] = 'xlsx';

$this->load->library('upload', $config);
$this->upload->initialize($config);
    
if (!$this->upload->do_upload()){
$data = array('msg' => $this->upload->display_errors());  
}
else {
$data['upload_data'] = $this->upload->data('flex_file');
}

$this->load->view('flex/thanks');

any wrong from my code, as I can't upload the file to the folder upload.
it keep go to the part in below (error):
Code:
if (!$this->upload->do_upload()){
$data = array('msg' => $this->upload->display_errors());  
}
#2

[eluser]CroNiX[/eluser]
upload dir is in a public place and has write permissions by the webserver user?

You are also passing config 2x, so something might be going wrong there. Once when you load the library, and then you also initialize() it. You should only need to do one of those.

What is the actual output of $this->upload->display_errors()?
#3

[eluser]hrg.vincent[/eluser]
[quote author="CroNiX" date="1393522314"]upload dir is in a public place and has write permissions by the webserver user?

You are also passing config 2x, so something might be going wrong there. Once when you load the library, and then you also initialize() it. You should only need to do one of those.

What is the actual output of $this->upload->display_errors()?[/quote]

once I deleted 1 of the config, it still the same.
doesn't display any error message, but it keep go to if statement, that's error part.
#4

[eluser]CroNiX[/eluser]
Well yeah, your code is assigning the error to a variable. You need to echo it or something.
#5

[eluser]hrg.vincent[/eluser]
[quote author="CroNiX" date="1393551194"]Well yeah, your code is assigning the error to a variable. You need to echo it or something.[/quote]

yes.. try to echo.. but still the same.. have no idea on this...
#6

[eluser]hrg.vincent[/eluser]
array
'error' => string '<p>You did not select a file to upload.</p>' (length=43)

Keep showing no file selected.
#7

[eluser]CroNiX[/eluser]
You need to tell do_upload() the name of your file input.
#8

[eluser]hrg.vincent[/eluser]
[quote author="CroNiX" date="1393562007"]You need to tell do_upload() the name of your file input.[/quote]

I've changed to code to below, but still the same issue, already added the name of input

Code:
if (!$this->upload->do_upload('flex_file')){
$error = array('error' => $this->upload->display_errors());
var_dump($error);  
}
else{
$data = array('upload_data' => $this->upload->data('flex_file'));
var_dump($data);
}




Theme © iAndrew 2016 - Forum software by © MyBB