doutingyou2198
2015-03-21 19:36
浏览 49
已采纳

无法获得实时服务器symfony 2上的路径

I have write a php code that upload the image to web/uploads/slider which i get through

$dir = $this->container->getParameter('assetic.write_to') . '\uploads\slider';

In my local server(windows apache) it works fine and upload as expected but the problem comes when i used it in live server it creates a folder name 'web\uploads\slider' in a project folder and upload a file in it

图片转代码服务由CSDN问答提供 功能建议

我写了一个php代码,将图像上传到web / uploads / slider,我通过

  $ dir = $ this-> container-> getParameter('assetic.write_to')。  '\ uploads \ slider'; 
   
 
 

在我的本地服务器(windows apache)中它工作正常并按预期上传但问题出现时我在实时服务器中使用它 它在项目文件夹中创建一个文件夹名称'web \ uploads \ slider'并在其中上传文件

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongzhang3482 2015-03-21 20:07
    已采纳

    You need to use forward slashes:

    $dir = $this->container->getParameter('assetic.write_to') . '/uploads/slider';
    

    Backslashes only work on Windows OS but forward slashes work on any OS (including Windows).

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题