I am attempting to create a directory in a WordPress Multisite subsite directory.
我正在尝试在WordPress Multisite子网站目录中创建一个目录。
The subsite directory is located at /home/site/site.com/wp-content/uploads/sites/site_id/
where site_id is the actual id# of the subsite.
子网站目录位于/home/site/site.com/wp-content/uploads/sites/site_id/,其中site_id是子网站的实际ID#。
I'm looking to create a directory under the site_id directory, and then add a file to that directory from elsewhere in my network.
我想在site_id目录下创建一个目录,然后从我网络中的其他位置向该目录添加一个文件。
Here is what I have so far:
这是我到目前为止:
// Get current site id
global $current_blog;
$shop_id = $current_blog->blog_id;
// Create directory for current site if does not exist
if (!file_exists(WP_CONTENT_DIR . '/uploads/sites/' . $shop_id . '/new-directory/')) {
mkdir(WP_CONTENT_DIR . '/uploads/sites/' . $shop_id . '/new-directory/', 0777, true);
}
//Copy download.php to new directory
$download_file = 'https://example.com/wp-content/plugins/new-directory/download.php';
$copy_download = 'https://example.com/wp-content/uploads/sites/' . $shop_id . '/new-directory/download.php';
if (!file_exists('https://example.com/wp-content/uploads/sites/' . $shop_id . '/new-directory/download.php')) {
copy($download_file, $copy_download);
}
When I run this, I get a failed to open stream: No such file or directory on line 30. Line 30 is the copy($download_file, $copy_download);
line.
当我运行它时,我得到一个未能打开的流:第30行没有这样的文件或目录。第30行是副本($ download_file,$ copy_download);线。
1 个解决方案
#1
As per OP's request to close the question.
根据OP要求结束这个问题。
Remove https://example.com
.
-
https://example.com/wp-content
actually, being a "joint venture".
https://example.com/wp-content实际上是一个“合资企业”。
copy
mostly only works on local files.
copy主要仅适用于本地文件。
- Consult the manual http://php.net/manual/en/function.copy.php
请参阅手册http://php.net/manual/en/function.copy.php
Plus, as I did think it (but didn't actually say it), to replace that with WP_CONTENT_DIR
in its place.
另外,正如我所想的那样(但实际上并没有这么说),用它取代WP_CONTENT_DIR。
#1
As per OP's request to close the question.
根据OP要求结束这个问题。
Remove https://example.com
.
-
https://example.com/wp-content
actually, being a "joint venture".
https://example.com/wp-content实际上是一个“合资企业”。
copy
mostly only works on local files.
copy主要仅适用于本地文件。
- Consult the manual http://php.net/manual/en/function.copy.php
请参阅手册http://php.net/manual/en/function.copy.php
Plus, as I did think it (but didn't actually say it), to replace that with WP_CONTENT_DIR
in its place.
另外,正如我所想的那样(但实际上并没有这么说),用它取代WP_CONTENT_DIR。