【发布时间】:2013-08-21 19:47:28
【问题描述】:
我正在使用 Codeigniter 的内置上传库。这些是我的上传设置:
$config['upload_path'] = upload_path() . 'incoming_faxes/';
$config['allowed_types'] = 'xml|pdf';
$config['file_name'] = uniqid('fax-' . time() . '-', true) . '.xml';
$this->load->library('upload', $config);
确实有效。返回的数据如下,但是file_name 后面有一个下划线:
Array
(
[file_name] => fax-1377114300-521518bca7c5a7.65243756_.xml
[file_type] => application/xml
[file_path] => /var/www/vhosts/example.org/httpdocs/uploads/incoming_faxes/
[full_path] => /var/www/vhosts/example.org/httpdocs/uploads/incoming_faxes/fax-1377114300-521518bca7c5a7.65243756_.xml
[raw_name] => fax-1377114300-521518bca7c5a7.65243756_
[orig_name] => fax-1377114300-521518bca7c5a7.65243756_.xml
[client_name] => Sample.xml
[file_ext] => .xml
[file_size] => 84.69
[is_image] =>
[image_width] =>
[image_height] =>
[image_type] =>
[image_size_str] =>
)
如何在文件上传到服务器之前去掉下划线?
【问题讨论】:
-
尝试将
'remove_spaces' => FALSE添加到您的配置数组中,看看是否能解决问题。默认情况下设置为 TRUE,但它应该只用下划线替换空格。这可能是文件上传类的 CI 错误。 -
@Fred-ii- 好主意,但没用。
-
在 SO stackoverflow.com/a/4074238/1415724 上查看这个答案
-
另请咨询github.com/EllisLab/CodeIgniter/issues/1380,但从我在cs.au.dk/~grav/hypweb/codeigniter/user_guide/libraries/… 上阅读的内容来看,
remove_spaces选项应该有效。另见techques.com/question/1-5728059/… -
检查
Line 994, _prep_filename()中的函数system->libraries->Upload.php file.取自此页面ch.runcode.us/q/…
标签: php codeigniter file-upload codeigniter-upload