- function auto_save_image($body){
- $img_array =explode('&',$body);
- /*$img_array = array();
- preg_match_all("/(src)=["|'| ] {0,}(http://(.*).(gif|jpg|jpeg|bmp|png))["|'| ]{0,}/isU", $body, $img_array);
- $img_array = array_unique($img_array[2]);*/ //自動合わせも可能
- set_time_limit(0);
- $imgPath = "uploads/allimg/".date("Ymd")."/";
- $milliSecond = strftime("%H%M%S",time());
- if(!is_dir($imgPath)) @mkdir($imgPath,0777);
- foreach($img_array as $key =>$value)
- {
- $value = トリム($value);
- $get_file = @file_get_contents($value);
- $rndFileName = $imgPath."/".$milliSecond.$key.".".substr($value,-3 ,3);
- if($get_file)
- {
- $fp = @fopen($rndFileName,"w");
- @fwrite($fp,$get_file);
- @fclose($fp);
- }
- $ body = @ereg_replace($value, $rndFileName, $body);
- }
- return $body;
- }
复制代
|