如何在其他网域上传档案? [英] How to upload file on another domain?
问题描述
我有一个外部托管服务器。
I have an external hosting server.
在该服务器上有两个域名:
On that server I have 2 domains:
-
www.dom1.com
-
www.dom2.com
www.dom1.com
www.dom2.com
在 www.dom1.com
我有我的整个网页(在Codeigniter中)。其中一项功能是上传(用户可以上传他们的文件。)
On www.dom1.com
I have my whole web page (in Codeigniter). One of the functionalities is upload (users can upload their files.)
在 www.dom2.com
只有一个名为upload_dom2的文件夹。 www.dom2.com
否则为空,在互联网上的任何地方都不可见。我想使用它专门用于上传。我想这是一个比让用户上传他们的文件在 www.dom1.com
一个更安全的方式,其中所有我的其他文件(顺便说一句,让我知道如果我错了。)
On www.dom2.com
there is only one folder called upload_dom2. www.dom2.com
is otherwise empty and not visible anywhere on the Internet. I would like to use it exclusively for upload. I imagine that this is a much safer way than letting the users upload their files on www.dom1.com
where all my other files are (by the way, let me know if I'm wrong, please).
那么,我该怎么办呢?如何上传文件 - 该用户已在 www.dom1.com
上的Codeignitors系统(网页)框架中上传了一个文件夹,名为upload-dom2 www.dom2.com
So, how do I do that? How do I upload a file - that user has uploaded in the framework of Codeignitors system (webpage) on www.dom1.com
- in a folder called upload-dom2 on www.dom2.com
我知道如何在名为uplod_dom1的文件夹中上传一个文件,位于 www.dom1.com
。这是我使用的代码。
I know how to upload a file in a folder called uplod_dom1 that is located on www.dom1.com
. This is a code that I use.
$pathd=$_SERVER['DOCUMENT_ROOT'];
$config['upload_path'] = $pathd.'/upload_dom1';
但是正如所说,这不是我想要的。我要上传到 www.dom2.com
(在其uplod-dom2文件夹中)。
But as said, that is not what I want. I want to upload to www.dom2.com
(in its uplod-dom2 folder).
我可以知道什么是正确的方式来实现我的目标?
May I know what is the correct way to achieve my objective?
推荐答案
看看Codeigniter FTP类。您可以使用支持FTP的任何外部网站/服务器执行此操作: http:// ellislab .com / codeigniter / user-guide / libraries / ftp.html
Take a look at the Codeigniter FTP class. You can do this with any external website/server that supports FTP: http://ellislab.com/codeigniter/user-guide/libraries/ftp.html
示例代码:
$this->load->library('ftp');
$config['hostname'] = 'ftp.example.com';
$config['username'] = 'your-username';
$config['password'] = 'your-password';
$config['debug'] = TRUE;
$this->ftp->connect($config);
$this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775);
$this->ftp->close();
这篇关于如何在其他网域上传档案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!