cam - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of cam.php

  1. <?php
  2.     
  3.     $img = $_POST['image'];
  4.     $folderPath = "upload/";
  5.   
  6.     $image_parts = explode(";base64,", $img);
  7.     $image_type_aux = explode("image/", $image_parts[0]);
  8.     $image_type = $image_type_aux[1];
  9.   
  10.     $image_base64 = base64_decode($image_parts[1]);
  11.     $fileName = uniqid() . '.png';
  12.   
  13.     $file = $folderPath . $fileName;
  14.     file_put_contents($file, $image_base64);
  15.   
  16.     print_r($fileName);
  17.   
  18. ?>
File Description
  • cam
  • PHP Code
  • 23 Aug-2019
  • 437 Bytes
You can Share it: