这是我的问题,我拿不到上传的file_name。这是我的代码:
控制器:
$file = array('upload_data' => $this->upload->data());
echo 'value =>'.$file['file_name'];
print_r($file);结果:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: file_name
Filename: controllers/uploading.php
Line Number: 38
value =>Array ( [upload_data] => Array ( [file_name] => Capture9.JPG [file_type] => image/jpeg [file_path] => C:/xampp/htdocs/Internship/asset/admin/img/ [full_path] => C:/xampp/htdocs/Internship/asset/admin/img/Capture9.JPG [raw_name] => Capture9 [orig_name] => Capture.JPG [client_name] => Capture.JPG [file_ext] => .JPG [file_size] => 30.88 [is_image] => 1 [image_width] => 589 [image_height] => 297 [image_type] => jpeg [image_size_str] => width="589" height="297" ) ) Rmk>上传工作,但我只需要获得文件名。谢谢
发布于 2015-01-27 22:45:30
file_name是您定义的名为$file的数组的属性。您希望使用$file['upload_data']['file_name']来访问它。
发布于 2015-01-28 03:54:10
注意multidimensional数组
您正在尝试访问['uploaded_data']数组的内部数组中的索引!因此,您必须使用$file['uploaded_data']['file_name'],最好检查数组是否有isset索引!:)
https://stackoverflow.com/questions/28173060
复制相似问题