I made an upload system where the user uploads a file and that file is saved and then read by php. The values are inserted into a database. The whole thing works great on the development server but not on the live server.
I have another upload system on the live site that works fine. I tried uploading it to a different folder but that didnt work either.
Just so you know the other day i had problems with the mime type. So for example i uploaded a csv file but the server read it as a text/plain document. I configured configured codeigniter to allow that for csv’s so that shouldnt be the problem. Just thought it was worth mentioning.
ERROR:
A PHP Error was encountered
Severity: Warning
Message: fopen(http://144.119.190.87/designUploads/testing.csv): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
Filename: controllers/headquarters.php
Line Number: 682
==================================================
PHP:
public function importDesign () {
// setting config options
$config['upload_path'] = './designUploads/';
$config['allowed_types'] = 'csv';
$config['overwrite'] = 'true';
// loading upload library
$this->load->library('upload', $config);
// write errors to view file
$error = '';
if (!$this->upload->do_upload('userfile')) {
$this->upload->delete($lastId);
} else {
$data = array('upload_data' => $this->upload->data());
}
$fileData = $this->upload->data();
$name = $fileData['file_name'];
Line 680 ---> if (($handle = fopen(base_url('designUploads/'. $name), "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$query = $this->db->query('
UPDATE rollout_systems
SET Mig_type = "'. $data[2] .'",
hardw_destination = "'. $data[3] .'",
new_model = "'. $data[4] .'",
new_system = "'. $data[5] .'",
Mig_Class = "'. $data[6] .'"
WHERE sys_name = "'. $data[0] .'"
AND EAM_User = "'. $data[1] .'"
');
if ($query) {
redirect('headquarters/migrationDetails');
}
}
fclose($handle);
}
}
Thanks to you two that tried to help. Found the problem while comparing both the uploads i have code. As it turns out fopen() does not support base_url(). Once i got rid of that it worked.