Reputation: 1
I have a PHP script that gets text as $name
from my android app and store image with the $name
as image name in my local XAMPP server in $path = "uploads/$name.png"
location .
When i type Persian/Arabic data it store them like:
ماست.png
ما ست.png
but it works like charm in English text :
carrot.png
Can any one help me to store the Persian/Arabic correctly as they typed?
Thanks.
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$image = $_POST['image'];
$name = $_POST['name'];
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
define('DB_NAME', 'android');
$conn = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
mysqli_set_charset($conn,"utf8");
$path = "uploads/$name.png";
$actualpath = "http://192.168.1.107/login1/image_up/$path";
$sql = "INSERT INTO imgnews (userNews,userMatn) VALUES ('$actualpath','$name')";
//
if(mysqli_query($conn,$sql)){
file_put_contents($path,base64_decode($image));
echo "Successfully Uploaded";
}
//mysql_real_escape_string($conn,$name);
mysqli_close($conn);
}else{
echo "Error";
}
i upload some pictures about my situation : enter image description here////
enter image description here////
Upvotes: 0
Views: 577
Reputation: 70
Make sure you have set you db collection to UTF-8 Then Add this header to your php script header('Content-Type: text/html; charset=utf-8'); your php Script should also support utf-8.
Upvotes: 1