[英]Codeigniter file upload - filename checking
I am working with uploading files in codeigniter, my problem is coming from that I have to file inputs, they are there to upload a file that is used by staff members and a file that cusstomers will see (sensitive data has been removed). 我正在使用Codeigniter上传文件,我的问题来自必须输入文件,他们在那里要上传供工作人员使用的文件和供客户查看的文件(敏感数据已删除)。
The client is going to be uploading the files name in this convention, 客户端将按照此约定上载文件名,
filename_parsed.pdf
filename_unparsed.pdf
How would I go about checking that the filename finishes with an _parsed
or _unparsed
? 我将如何检查文件名是否以_parsed
或_unparsed
?
CodeIgniter has a helper function for files...make sure the file helper is loaded CodeIgniter具有文件的帮助程序功能...确保已加载文件帮助程序
$var = get_file_info('path/to/file','name')
if(strpos($var,'_unparsed') !== false) {
// Do stuff
} else if(strpos($var,'_parsed') !== false) {
// Do stuff
}
if(preg_match('/(_(un|)parsed)$/', $file_name))
{
//tests for:
// _unparsed
// _parsed
//Important not to include the file ext otherwise will fail
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.