问题描述
我有两个项目或网址
第一个网址是这样的:
这样的第二个网址:
如果第二个URL,我上传图像,它将图像文件保存在这里:
If the second url, I upload image it will save the image file here :
http://myshop.dev/img/image1.jpg
两个项目都使用相同的数据库
Both projects use the same database
我要在第二个项目上上传图像的代码,如下所示:
My code to upload image on the second project like this :
public function __construct(...)
{
...
$this->path = './img';
}
...
public function store(...) {
...
$filename = Input::file('photo')->getClientOriginalName();
...
Input::file('photo')->move($this->path, $filename);
...
}
有效
如果我上传图片,它将图片保存在backend-myshop \ public \ img
If I upload image it will save the image in backend-myshop\public\img
但是,我要上传未保存的图像.但是在我的第一个项目中
But, I want to uploaded image not saved there. But in my first project
所以,我想将图像文件保存在这里:myshop \ public \ img
So, I want the image file saved here : myshop\public\img
我该怎么办?
推荐答案
您好,在将它们从backend-myshop \ public \ img复制到myshop \ public \ img后,您可以使用此存储复制方法
Hi after uploading copy them from backend-myshop\public\img to myshop\public\img you can use this storage copy method
public function store(...) {
...
$filename = Input::file('photo')->getClientOriginalName();
...
Input::file('photo')->move($this->path, $filename);
Storage::copy('backend-myshop/public/img/'.$filename, 'myshop/public/img/'.$filename);
...
}
希望这可以解决您的问题
hope this will solve your problem
这篇关于如何将图像上传到Laravel上的其他项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!