This code is working. it saves the photo using webcam.js. the problem is when I'm saving file with the file name of Peña its not working. I got a result of Peña.jpg or Pe?a.jpg file name. but in the database I got it right(peña).
The problem is on the file_put_contents and rename function.
$photoname = $_POST['photoname'];
$date1 = date('Ymd');
$photo_file = 'photos/'.$date.'/'.$date."".$photoname.".jpg";
$encoded_data = $_POST['mydata'];
$binary_data = base64_decode( $encoded_data );
if (!is_dir('photos/' . $month)) {
// dir doesn't exist, make it
mkdir('photos/' . $month);
}
/*get the image */
$result = file_put_contents($photo_file, $binary_data);
rename function (its also working without special characters).
$fname = utf8_decode($_POST['fname']);
$mname = utf8_decode($_POST['mname']);
$lname = utf8_decode($_POST['lname']);
$photo_old = $_POST['photopath'];
$photoname = utf8_decode(strtolower($fname. ''. $mname.''.$lname));
$date1 = date('Ymd');
$month = date('Ymd');
$photo_final = 'photos/'.$month.'/'.$date1."".$photoname.".jpg";
rename($photo_old, $photo_final);
result:
Warning: rename(photos/20150929/20150929Peña.jpg,photos/20150930/20150930Pe?a.jpg)