Salve questo è il mio codice:
<body>
    <form id="form">
      <input id="user" type="username" placeholder="username">
      <input type="submit" value="Submit">
    </form>
    <!--Disegno canvas-->
    
      $('#form').bind('submit', function(e){
        e.preventDefault();
        var username = $('#user').val();
        localStorage.setItem('form-username', JSON.stringify(password));
      });
      // save canvas image as data url (png format by default)
      var dataURL = canvas.toDataURL();
      // set canvasImg image src to dataURL
      // so it can be saved as an image
      document.getElementById('canvasImg').src = dataURL;
      $.ajax({
        type: "POST",
        url: "http://localhost:9980/php/test.php",
        data: {
           imgBase64: dataURL
        }
      }).done(function(response) {
        console.log('saved: ' + response);
      });
    </script>
  </body>
<?php
	define('UPLOAD_DIR', 'images/');
	$img = $_POST['imgBase64'];
	$img = str_replace('data:image/png;base64,', '', $img);
	$img = str_replace(' ', '+', $img);
	$data = base64_decode($img);
	$file = UPLOAD_DIR . uniqid() . '.png';
	$success = file_put_contents($file, $data);
	//send request to ocr 
	print $success ? $file : 'Unable to save the file.';
?>
La prima domanda è come faccio a salvare il nome dell'immagine che in questo caso è univoco, mi sembra, con il nome inserito nell'input form username.
La seconda domanda è se volessi mettere questo sito on line avrò problemi con i permessi per scrivere dentro la cartella dove salvo l'immagine?