所以我得到了这个错误并且搜索到处都是有原因的。从我所看到的这个代码应该工作。它不使用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);
}
}
}
答案 0 :(得分:0)
HTTP包装器不允许写入(有充分理由)所以这不会以你希望的方式工作,你需要一个允许写入的流,如:
(最好)文件:http://php.net/manual/en/wrappers.file.php