简体   繁体   English

如何在laravel 3的php apache2中的其他目录中存储和显示图像

[英]how to store and display images in other directory in php apache2 in laravel 3

my directory structure is like (in ubuntu) 我的目录结构就像(在ubuntu中)

  /var/www/mysite/application/(here is code)

i want to store my uploaded photos in 我想将上传的照片存储在

  /var/www/mysite/uploads/(a.jpg) 

should i use alias in .htacccess file for directory so that it will not expose to other users, where actually directory resides ? 我应该在.htacccess文件中为目录使用别名,以便它不会暴露给目录所在的其他用户吗? but in that case how to display that file in 但是在那种情况下,如何在

i refer other Question they said i should use 我提到他们说我应该使用的其他问题

header('Content-type: image/jpeg');
 readfile('/path/to/picture/outside/doc/root/file.jpg');

can you gus plz tell me how to store photos in above mentioned directory structure ? 您能告诉我如何在上述目录结构中存储照片吗?

It depends where is your public folder. 这取决于您的公用文件夹在哪里。 If it is the ..../my site/ then just in the config folder set the images folder to be the uploads or use URL::to_asset to point to the specific file. 如果是.... / my site /,则只需在config文件夹中将images文件夹设置为上载,或使用URL :: to_asset指向特定文件。 could you tell me where is your public folder of Laravel? 您能告诉我您的Laravel公用文件夹在哪里吗?

Another - exotic - solution would be to use a "proxy" route that would return the requested image via code. 另一个解决方案是使用“代理”路由,该路由将通过代码返回请求的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM