phpmoduleprestashop

Add a field "CREATE AN ACCOUNT" using prestashop


I am very newbie for prestashop. my image name is saving perfectly in databse. but while during image uploading create error 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. i am using the code for uploading

   $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;
    }  

}

I am using 1.4.3.


Solution

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

    You should use a local path and not an HTTP URI.

    As mentioned in your comment $new_path = dirname(FILE) . "/uploads/" . $_FILES["profile_image"]['name']; is the solution.