2013-02-14 71 views
0

我在手術/ PatientBundle/Constroller/RegistrationPatientBundleController和Surgery/PatientBundle/Resources/public/images/test.jpg中有控制器。我有一個圖像。這幅圖像的路徑如何?我在我的控制器中試過這個代碼PHP GD庫,Symfony中圖像的路徑

public testAction(){ 

    header ('Content-Type: image/jpeg'); 
    $image = imagecreatefromjpeg("../Resources/public/images/test.jpg"); 
    imagejpeg($image); 

但是找不到文件。

回答

0

嘗試:

$image => imagecreatefromjpeg(__DIR__.'/../Resources/public/images/test.jpg'); 
+0

我不得不添加 「/」,但它的工作原理$圖像= imagecreatefromjpeg(__ DIR __ '/ .. /資源/公/圖片/ sara.jpg'); – konadrian 2013-02-14 15:12:51