我能够只在子域A中上传图片,但无论我怎么做,都不能上传到B中,这是我的情况。
$move_to = $_SERVER['DOCUMENT_ROOT'] . "/assets/pinturas/$timestamp-" . $file;
$move_to_site = $this->config->item('testing_domain_root') . "/assets/pinturas/$timestamp-" . $file;
$outputThis = move_uploaded_file($_FILES['nuevaPintura']['tmp_name'], $move_to);
$outputOther = move_uploaded_file($_FILES['nuevaPintura']['tmp_name'], $move_to_site);
这个变量 $this->config->item('testing_domain_root')
相当于... $_SERVER['DOCUMENT_ROOT']
(我做的是一样的,只是子域不同)。
然而,当检查 move_uploaded_file
方法,本地的那个(子域A)给我的是 "true",而子域B什么也不返回。
两个子域都存在于同一个服务器中,所以我不明白为什么会发生这种情况。
move_uploaded_file()函数将源文件移动到另一个位置。只是你不能移动同一个文件两次。
作为一个替代的解决方案,你可以将被移动的文件复制到第二个位置。
$outputOther = copy($move_to, $move_to_site);