CodeIgniter Forums
File Upload error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: File Upload error (/showthread.php?tid=60311)



File Upload error - El Forum - 02-27-2014

[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());  
}



File Upload error - El Forum - 02-27-2014

[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()?


File Upload error - El Forum - 02-27-2014

[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.


File Upload error - El Forum - 02-27-2014

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


File Upload error - El Forum - 02-27-2014

[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...


File Upload error - El Forum - 02-27-2014

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

Keep showing no file selected.


File Upload error - El Forum - 02-27-2014

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


File Upload error - El Forum - 02-27-2014

[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);
}