HTTP包装器不支持可写连接


HTTP wrapper does not support writeable connections WordPress

所以我得到这个错误,到处搜索的原因。从我所读的这段代码应该工作。它不是使用url来写入文件,而是使用相对路径。所有的文件权限都设置在755上,所以不要认为这是问题所在。我甚至有一个插件开发人员看了一下,他没有发现问题。有人知道为什么会出现这个错误吗?

错误:

`Warning: move_uploaded_file(http://************/wp-content/uploads/simpleecommcart/digitalproduct/13-1.jpg): failed to open stream: HTTP wrapper does not support writeable connections in /home/***********/public_html/wp-content/plugins/simple-e-commerce-shopping-cart/models/SimpleEcommCartProduct.php on line 880`
`Warning: move_uploaded_file(): Unable to move '/tmp/phpyv2ztG' to 'http://***********/wp-content/uploads/simpleecommcart/digitalproduct/13-1.jpg' in /home/stagingpeak/public_html/wp-content/plugins/simple-e-commerce-shopping-cart/models/SimpleEcommCartProduct.php on line 880`

上传代码(我在错误的地方写了880):

    //check for product image upload 
    if(strlen($_FILES['product']['tmp_name']['image_upload']) > 2) {
      $dir = SimpleEcommCartSetting::getValue('product_folder');
      if($dir) {
        $filename = preg_replace('/'s/', '_', $_FILES['product']['name']['image_upload']);
        $path = $dir . DIRECTORY_SEPARATOR . $filename;
        $src = $_FILES['product']['tmp_name']['image_upload'];
 880-->     if(move_uploaded_file($src, $path)) {
          $_POST['product']['product_image_path'] = $filename;
        }
        else {
          $this->addError('Product Image File Upload', __("Unable to upload file","simpleecommcart"));
          $msg = "Could not upload file from $src to $path'n". print_r($_FILES, true);
          throw new SimpleEcommCartException($msg, 66101);
        }
      }
    }

HTTP包装器不允许写入(有很好的理由),所以这不会以您希望的方式工作,您需要一个允许写入的流,例如:

(优选)文件:http://php.net/manual/en/wrappers.file.php

FTP: http://php.net/manual/en/wrappers.ftp.php

来源:http://php.net/manual/en/wrappers.http.php