请问我有事要问你
我需要删除此代码生成的文件的空格。现在原始代码如下!
$small_file = $image->createFile(' '.$filename);
关键是我需要那个''因为否则它将无法工作..我的意思是代码!现在,我需要的是类似下面的内容,这将允许我在提交之前删除从代码生成的空格。
$small_file = $image->REMOVE_SPACES[createFile(' '.$filename)];
function createFile($output_filename = null) {
if($this->ext == "JPG" OR $this->ext == "JPEG") {
imageJPEG($this->dst_r, $this->uploaddir.$output_filename, $this->quality);
} elseif($this->ext == "PNG") {
imagePNG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
} elseif($this->ext == "GIF") {
imageGIF($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
}
return $output_filename;
}
$filename = $_FILES['Filedata']['name'];
所有代码:
function createFile($output_filename = null) {
if($this->ext == "JPG" OR $this->ext == "JPEG") {
imageJPEG($this->dst_r, $this->uploaddir.$output_filename, $this->quality);
} elseif($this->ext == "PNG") {
imagePNG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
} elseif($this->ext == "GIF") {
imageGIF($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
}
return $output_filename;
}
function setUploadDir($dirname) {
$this->uploaddir = $dirname;
}
function flush() {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
$filename = $_FILES['Filedata']['name'];
imagedestroy($this->dst_r);
unlink($targetFile);
imagedestroy($this->img_r);
}
}
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
$filename = $_FILES['Filedata']['name'];
$thumbnail = basename($filename,'.' .$ext) . $ext;
$thumbnail1 = basename($filename);
move_uploaded_file ($tempFile, $targetFile);
$image = new Image();
$image->setFile($targetFile);
$image->setUploadDir($targetPath);
$image->resize(640);
$large_file = $image->createFile(' '.$thumbnail1);
$image->resize(120);
$small_file = $image->createFile('s_'.$thumbnail);
$image->flush();
}
谢谢您的支持!