// Other variables
$MAX_FILENAME_LENGTH = 260;
$file_name = $_FILES[$upload_name]['name'];
//echo "testing-".$file_name."<br>";
//$file_name = strtolower($file_name);
$file_extension = end(explode('.', $file_name)); //ERROR ON THIS LINE
$uploadErrors = array(
0=>'There is no error, the file uploaded with success',
1=>'The uploaded file exceeds the upload max filesize allowed.',
2=>'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
3=>'The uploaded file was only partially uploaded',
4=>'No file was uploaded',
6=>'Missing a temporary folder'
);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?2天后仍然卡住了.
$el = array_shift($instance->find(..))
Run Code Online (Sandbox Code Playgroud)
上面的代码以某种方式报告了严格的标准警告,但这不会:
function get_arr(){
return array(1,2);
}
$el = array_shift(get_arr());
Run Code Online (Sandbox Code Playgroud)
那么它什么时候会报告警告呢?
我们可以从$ _FILES ["file"] ["tmp_name"]中找出原始文件的扩展名吗?例如jpg或png等?谢谢.
我有一个允许用户上传文件的表单,但我需要获取文件扩展名,我能够获得,但不确定我是否使用最有效的解决方案
我可以通过以下方式获得它
$fileInfo = pathinfo($_FILES['File']['name']);
echo $fileInfo['extension'];
$ext = end(explode('.',$_FILES['File']['name']));
echo $ext;
Run Code Online (Sandbox Code Playgroud)
哪种方法最好使用,或者是否有更好的解决方案可以获得扩展?