我制作了一个上传系统,用户上传一个文件,该文件被保存,然后由 php 读取。这些值被插入到数据库中。整个事情在开发服务器上运行良好,但在实时服务器上却不行。
我在现场网站上有另一个工作正常的上传系统。我尝试将其上传到不同的文件夹,但也没有用。
只是让你知道前几天我对 mime 类型有问题。例如,我上传了一个 csv 文件,但服务器将其作为文本/纯文档读取。我配置了配置的codeigniter以允许csv的,所以这不应该是问题。只是觉得值得一提。
错误:
遇到 PHP 错误
严重性:警告
消息:fopen(http://144.119.190.87/designUploads/testing.csv):打开流失败:HTTP 请求失败!HTTP/1.1 401 未经授权
文件名:controllers/headquarters.php
行号: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);
}
}