在 cakephp 的 webroot/img 文件夹之外上传图像
我正在使用 CakePHP 构建一个 Web 应用程序。我正在使用 meioupload 上传图像。这些图像已成功上传。当然,我想将 admin-app 和 public-app 分成两个单独的 CakePHP 应用程序。问题是我无法与管理应用程序的 webroot 共享上传到公共应用程序的 webroot 的图像,反之亦然。我正在考虑将这些图像上传到这两个应用程序之外的另一个文件夹中。我走在正确的轨道上吗?如果我是,我该怎么办?
谢谢。
I am building a web application using CakePHP. I am using meioupload to upload the images. These images are successfully uploaded. I would like to separate the admin-app and public-app into, of course, two separate CakePHP applications. The problem is that I can't share the images that were uploaded into the public-app's webroot with the admin-app's webroot and vice versa. I am thinking about uploading these images into another folder outside those two apps. Am I on the right track? If I am, how can I do this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种解决方案是修改脚本以将图像上传到两个应用程序都可以查看的“共享”目录。或者,如果您使用的是类似 Linux 的操作系统,则可以在文档根目录下创建此共享目录,并在每个应用程序将调用的目录之间创建符号链接。
因此 APP1 和 APP2 都可以上传到
/var/sharedStuff
。 APP1 位于/var/www/app1
,APP2 位于/var/www/app2
这两个应用程序都可以有一个符号链接到 shareStuff 目录的目录。因此/var/www/app1/app/webroot/img/shared
和/var/www/app2/app/webroot/img/shared
都将在内部指向 <代码>/var/sharedStuff。然后,您可以从应用程序引用这些图像,就像将它们放置在img/shared
目录中一样。同样,您需要修改上传脚本以确保它将文件上传到此共享目录(或符号链接)而不是独占目录。只是想让您知道,CakePHP 具有用于创建您自己的管理界面的内置功能。那里有很多教程。只需谷歌搜索即可。将它们分成两个应用程序似乎不太理想。
One solution is to modify your script to upload your images to a "shared" directory which can be view by both applications. Or, if you're on a Linux-like OS, you could make this shared directory under the document root and have a symbolic link created between the directories that each application will call.
So APP1 and APP2 could both upload to
/var/sharedStuff
. APP1 is located at/var/www/app1
and APP2 is located at/var/www/app2
Both of these apps could have a directory that is symlinked to the sharedStuff directory. So/var/www/app1/app/webroot/img/shared
and/var/www/app2/app/webroot/img/shared
would both internally point to/var/sharedStuff
. You could then reference these images from your application just as if they were placed in thatimg/shared
directory. Again, You'd need to modify your upload script to make sure it uploads files to this shared directory (or symlink) and not in an exclusive one.Just to let you know, CakePHP has built in functionality for creating your own admin interface. There are many tutorials out there. Just a Google search away. Separating them into two applications seems less than ideal.
使用 meioupload ,事实证明我可以使用相对路径,所以我这样做:
using meioupload, it turn out that i can use relative path, so i do it like this: