使用prestashop

时间:2016-06-24 21:59:30

标签: module prestashop

我是prestashop的新手。我的图像名称在数据库中完美保存。但在图片上传过程中会产生错误warning failed to open stream: HTTP wrapper does not support writeable connections in /opt/lampp/htdocs/xyz.com/shop/controllers/AuthController.php on line 427。 我正在使用代码上传

   $customer->profile_image = $this->uploadProfileImage(); // call function

    public function uploadProfileImage() { // this is function
    if(isset($_FILES['profile_image'])){
        $target_file = "http://192.168.1.10".__PS_BASE_URI__.'upload';
        $fileName = str_replace(" ", "-", $_FILES["profile_image"]["name"]); 
        $name = pathinfo($fileName, PATHINFO_FILENAME);
        $extension = pathinfo($fileName, PATHINFO_EXTENSION);
        $increment = '';
        while(file_exists($target_file.$name . $increment . '.' .$extension)) {
                $increment++;
        }
        $basename =$name.$increment.'.'.$extension;  

        $filen = $_FILES['profile_image']['tmp_name']; 
        move_uploaded_file($filen, $target_file.$basename );
        return $basename;
    }  

}

我正在使用1.4.3。

1 个答案:

答案 0 :(得分:0)

$target_file = "http://192.168.1.10".__PS_BASE_URI__.'upload';

您应该使用本地路径而不是HTTP URI。

正如您的评论$new_path = dirname(FILE) . "/uploads/" . $_FILES["profile_image"]['name'];所述,是解决方案。