使用PHP生æˆå”¯ä¸€çš„文件å?

时间:2016-10-07 15:45:03

标签: php

我使用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;

0 个答案:

没有答案