遇到PHP错误
严重性:注意
消息:未定义的索引:扩展名
文件名:vadmin / ajax.php
行号:88
这是我的代码
$org_filename = $_FILES['userfile']['name'];
$path_parts = pathinfo($org_filename);
$file_extension = $path_parts['extension'];
/***** end extracting file extension ******/
$config['upload_path'] = './uploads/news';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1024 * 1000;
$final_file_name = $config['file_name'] = 'news_'.time().'.'.$file_extension;
答案 0 :(得分:0)
尝试在pathinfo()
中传递PATHINFO_EXTENSION
$org_filename = $_FILES['userfile']['name'];
$file_extension = pathinfo($org_filename, PATHINFO_EXTENSION);
或substr()
: -
$file_extension = substr($org_filename, strrpos($org_filename, '.')+1);