Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在[codeigniter]中使用随机名称规则上载图像_Php_Codeigniter_Tinymce_File Manager - Fatal编程技术网

Php 如何在[codeigniter]中使用随机名称规则上载图像

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

我使用TinyMCE文件管理器上传图像,但每次存储时都使用原始名称

是否仍然可以设置名称规则(通过PHP),如:

图像{auto_increment_number}


谢谢

在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()。“_图像”

希望这对你有帮助