2

I already tried validating if the canvas/screenshot worked and it says that it did. I guess the problem is that it isn't uploaded to the directory.

I also already tried enabling the fileUpload option in the Cpanel of the hostinger.

I also tried altering the directory but it still doesnt work, but it works perfectly fine in my localhost.

if($_POST['image'] != null){
    
    $image = $_POST['image'];
    $picpath = $_POST['picpath']; 

    $image_parts = explode(";base64,", $image);

    $image_base64 = base64_decode($image_parts[1]);
    
    $fileLocation = "./public_html/SBAdmin2/includes/customuploads/".$picpath;
    file_put_contents($fileLocation, $image_base64);


}
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
caps
  • 21
  • 2

1 Answers1

0

Try something like:

    // ...

    $fileLocation = __DIR__ . '/public_html/SBAdmin2/includes/customuploads/' . $picpath;
    file_put_contents($fileLocation, $image_base64);
}

Note that "./" refers to current-directory, which may not be what you expect, and on servers it may refer to another directory.

Top-Master
  • 7,611
  • 5
  • 39
  • 71