我使用php script将图片上传到目录。 我试图弄清楚为什么脚本在将图像保存到目录之前不给图像一个唯一的文件名。我一次只上传一张图片,我在这里包含了相关的php,我认为这会创建独特的文件名。谁能告诉我为什么图像没有得到独特的名字?
//proportionally resize image
private function resize_it(){
if($this->file_count > 0){
if(!is_array($this->file_data['name'])){
throw new Exception('HTML file input field must be in array format!');
}
for ($x = 0; $x < $this->file_count; $x++){
if ($this->file_data['error'][$x] > 0) {
$this->upload_error_no = $this->file_data['error'][$x];
throw new Exception($this->get_upload_error());
}
if(is_uploaded_file($this->file_data['tmp_name'][$x])){
$this->curr_tmp_name = $this->file_data['tmp_name'][$x];
$this->get_image_info();
//create unique file name
if($this->random_file_name){
$this->new_file_name = uniqid().$this->get_extension();
$this->unique_rnd_name[$x] = $this->new_file_name;
}else{
$this->new_file_name = $this->file_data['name'][$x];
}
$this->curr_tmp_name = $this->file_data['tmp_name'][$x];
$this->image_res = $this->get_image_resource();
$this->save_dir = $this->destination_dir;