[英]Upload file to different domain on same Server
I'm confused about the path..!!! 我对这条路感到困惑.. !!!
I want to upload a files to a another domain hosted on same server. 我想将文件上传到同一服务器上托管的另一个域。
STRUCTURE: 结构体:
-> abc.com - application - assets - upload - system -> xyz.com - application - system
Im running an upload function in www.xyz.com
and I want to save the file inside the folder in www.abc.com
. 我在
www.xyz.com
运行上传功能,我想将文件保存在www.abc.com
的文件夹内。
I use the following line as path: 我将以下行用作路径:
$path = $_SERVER['DOCUMENT_ROOT'].'/abc.com/assets/upload/'.$video_file_name;
The above path work fine in localhost server.
上面的路径在localhost服务器上工作正常。
But it return a path like this: 但它返回的路径是这样的:
/home/www/xyz.com/abc.com/assets/upload/vid_15155833651401821.mp4
I need the path as: 我需要的路径为:
/home/www/abc.com/assets/upload/vid_15155833651401821.mp4
CODE: 码:
function video()
{
if(isset($_POST["submit"]))
{
$extension = pathinfo($_FILES['videourl']['name'][0], PATHINFO_EXTENSION);
$video_file_name = 'vid_'.time().rand(0,10000000).'.'.$extension;
$path = $_SERVER['DOCUMENT_ROOT'].'/abc.com/assets/upload/'.$video_file_name;
// $path = $_SERVER['DOCUMENT_ROOT'].'/../abc.com/assets/upload/'.$video_file_name;
// $path = 'home/www/abc.com/assets/upload/'.$video_file_name;
move_uploaded_file($_FILES["videourl"]["tmp_name"][0],$path);
echo $video_file_name;
}else{
$this->load->view('test');
}
}
You need to go "up" a directory, since the xyz.com
shouldn't be there. 您需要进入“目录”,因为
xyz.com
不应存在。 So based on your current code, replace: 因此,根据您当前的代码,替换:
$path = $_SERVER['DOCUMENT_ROOT'].'/abc.com/assets/upload/'.$video_file_name;
With 用
$path = $_SERVER['DOCUMENT_ROOT'].'/../abc.com/assets/upload/'.$video_file_name;
Effectively adding the ../
after the document root variable. 有效地在文档根变量之后添加
../
。 This should put the file in the right place. 这应该将文件放在正确的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.