Reputation: 55
I made a simple php form for uploading photos. What is important to me is that the photograph retains its original name with Bosnian letters č, ć, ž, š, đ. Everything is fine until the Bosnian letter is capitalized at the beginning of the name (Č, Ć, Ž, Š, Đ). Then it is simply left out, so the photo Žuti.jpg becomes uti.jpg How to solve this problem?
Tis is my code
<?php
if(isset($_FILES['image'])){
$errors= array();
foreach($_FILES['image']['tmp_name'] as $key => $tmp_name ){
$file_name =$_FILES['image']['name'][$key];
$file_size =$_FILES['image']['size'][$key];
$file_tmp =$_FILES['image']['tmp_name'][$key];
$file_type=$_FILES['image']['type'][$key];
// get file extension
$fileType = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
// get filename without extension
$fileNewName = pathinfo($file_name, PATHINFO_FILENAME);
$watermarkImagePath = '2000/images/watermark.png';
$folderPath = "2000/images/$alias/";
$sourceProperties = getimagesize($file_tmp);
$imageType = $sourceProperties[2];
// Resize and watermark code.
.
.
.
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image[]" multiple/>
<input type="submit" value="Pošalji"/>
</form>
Upvotes: 0
Views: 120
Reputation: 55
The problem was solved by adding:
setlocale(LC_ALL,'bs_BA.UTF-8');
Before:
$fileType = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
Upvotes: 1