Php 如何在[codeigniter]中使用随机名称规则上载图像
我使用TinyMCE文件管理器上传图像,但每次存储时都使用原始名称 是否仍然可以设置名称规则(通过PHP),如: 图像{auto_increment_number}Php 如何在[codeigniter]中使用随机名称规则上载图像,php,codeigniter,tinymce,file-manager,Php,Codeigniter,Tinymce,File Manager,我使用TinyMCE文件管理器上传图像,但每次存储时都使用原始名称 是否仍然可以设置名称规则(通过PHP),如: 图像{auto_increment_number} 谢谢 在codeigniter中,您可以在一个变量中获取上传的文件或图像名称,然后用另一个随机数附加该变量 $upload_data = $this->upload->data(); //Returns array of containing all of the data related to the file you
谢谢 在codeigniter中,您可以在一个变量中获取上传的文件或图像名称,然后用另一个随机数附加该变量
$upload_data = $this->upload->data(); //Returns array of containing all of the data related to the file you uploaded.
$file_name = $upload_data['file_name'];
$append_value = 'value';
$file_name .= '_'.$append_value;
希望这对您有所帮助您可以使用PHPuniqid()函数,该函数根据微时间(当前时间以微秒为单位)生成唯一的ID。它将始终创建一个唯一的文件名,而不会出现重复问题 $newimagename=uniqid()。“_图像” 希望这对你有帮助