I've recently migrated my website to PHP 7.3. There is an input box where I allow the user to upload a picture using their media device. Since upgrading, I get a few "Use of undefined constant..." errors.
Here is the PHP code:
function hasGetUserMedia() {
return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia);
}
if (hasGetUserMedia()) {
echo '<input type="file" accept="image/* application/pdf" capture="camera" name="expimage" id="expimage" onchange="setExif(this.files)" />';
}
Although the code works, the webpage shows the following warnings:
Warning
: Use of undefined constant navigator - assumed 'navigator' (this will throw an Error in a future version of PHP)
Warning
: Use of undefined constant mediaDevices - assumed 'mediaDevices' (this will throw an Error in a future version of PHP)
Warning
: Use of undefined constant navigator - assumed 'navigator' (this will throw an Error in a future version of PHP)
Warning
: Use of undefined constant mediaDevices - assumed 'mediaDevices' (this will throw an Error in a future version of PHP)
Warning
: Use of undefined constant getUserMedia - assumed 'getUserMedia' (this will throw an Error in a future version of PHP)
I'm following WebRTC. What is the new format for defining the constants?