2012-05-22 73 views
0

我想弄清楚它把新的调整大小的图像在这里。PHP的图像调整大小获取名称和路径

function createFile($output_filename = null,$imageNewName) { 
     if($this->ext == "JPG" OR $this->ext == "JPEG") { 
      imageJPEG($this->dst_r, $this->uploaddir.$imageNewName.'.'.$this->ext, $this->quality); 
     } elseif($this->ext == "PNG") { 
      imagePNG($this->dst_r, $this->uploaddir.$imageNewName.'.'.$this->ext); 
     } elseif($this->ext == "GIF") { 
      imageGIF($this->dst_r, $this->uploaddir.$imageNewName.'.'.$this->ext); 
     } 
     $this->output = $this->uploaddir. $imageNewName; 

     echo $this->uploaddir. $imageNewName .'.'.$this->ext; 
} 

function resize($newWidth, $newHeight) { 
    $width = imagesx($this->img_r); 
    $height = imagesy($this->img_r); 

    $newWidth = $newWidth; 
    $newHeight = $newHeight; 

    $this->dst_r = ImageCreateTrueColor($newWidth, $newHeight); 
    imagecopyresampled($this->dst_r, $this->img_r, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); 
    $this->img_r = $this->dst_r; 
    $this->img_h = $newHeight; 
    $this->img_w = $newWidth; 
} 

    $tempFile = $_FILES['Filedata']['tmp_name']; 
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/img/nonfb/'; 

$fileNameBase = $_FILES['Filedata']['name']; 
$extension = pathinfo($fileNameBase, PATHINFO_EXTENSION); 
$fileNameNEW = $imageNewName . '.' . $extension; 

$targetFile = str_replace('//','/',$targetPath) . $fileNameNEW; 
echo 'TARGET=' . $targetFile; 

move_uploaded_file ($tempFile, $targetFile); 

$image = new Image(); 
$image->setFile($targetFile); 
$image->setUploadDir($targetPath); 
$image->resize(50,50); 
$image->createFile(md5($tempFile,$fileNameNEW)); 
$image->flush() 

我可以告诉它走的是dst_r作为当前图像和IMG_R作为资源图像但林不知道如何使用呼应这些,找出它们的值。我想要做的是找出它的位置,调整大小的图像,所以我可以重命名它。

任何帮助将是伟大的!

+0

dst_r/IMG_R的价值观是无用的。它们只是GD资源句柄,并且在当前正在执行的脚本的上下文之外没有意义。 –

+0

$ _REQUEST ['folder']看起来不太安全 – Scuzzy

回答

1

我假设这段代码驻留在一个类中。正如createFile功能的第9行,该文件可能会驻留在此路径:

echo $this->uploaddir. $imageNewName .'.'.$this->ext; 
+0

好吧,我改变了它,但我一直得到相同的错误。检查我的OP。 – StealthRT

+0

它看起来像最后一行之前的行是错误的:'$ image-> createFile(md5($ tempFile,$ fileNameNEW));'应该可能是'$ image-> createFile(md5($ tempFile),$ fileNameNEW) ;'。注意括号。 – devsnd

+0

好吧,我做了这个更正,现在通过这个名字..现在好像把图像放在正确的名称模式中......那最后一个错误怎么样?检查更新的OP。 – StealthRT