perldancer2 文件上传代码

perldancer 可能很少用,贴出来希望你能通过百度找到这里,webeditor 用的是wangEditor,上传目录为/upload

post '/upload' =>needs login=>sub{
	my $upload = upload('wangEditorH5File');
	my $filename = md5_hex(time);
	my $tmp=$upload->{tempname};
	
	my $suffix='';  #后缀
	
	if(index('.',$tmp)){
		$suffix=(split(/\./,$tmp))[-1];
	}
	my $webpath='/upload/';
	my $full_name=$filename.'.'.$suffix;
	
	$upload->copy_to(config->{appdir}."/public$webpath/$full_name");
	
	return $webpath.$full_name;
};