0

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>

1 Answer 1

1

The problem was solved by adding:

setlocale(LC_ALL,'bs_BA.UTF-8');        

Before:

$fileType = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.