i have a php image upload script that inserts image url in data base . when using a web broswer it works just fine But when useing a smart phone it will not upload the image What Do i need to do fix
// Create database connection
$db = mysqli_connect("localhost", "username", "password", "dbname");
// Initialize message variable
$msg = "";
// If upload button is clicked ...
if (isset($_POST['upload'])) {
// Get image name
$image = $_FILES['image']['name'];
// Get text
$image_text = mysqli_real_escape_string($db, $_POST['image_text']);
// image file directory
$target = "upload/".basename($image);
$sql = "INSERT INTO images (image, image_text) VALUES ('$image', '$image_text')";
// execute query
mysqli_query($db, $sql);
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
$msg = "Image uploaded successfully";
}else{
$msg = "Failed to upload image";
}
}
$result = mysqli_query($db, "SELECT * FROM images");
?>
<!DOCTYPE html>
<html>
<head>
<title>Image Upload</title>
</head>
<body style="width: 222px">
<div id="content">
<?php
while ($row = mysqli_fetch_array($result)) {
echo "<div id='img_div'>";
echo "<img height=\"151\" src=/upload/".$row['image']." width=\"209\">\n";
echo "Summited By<p>".$row['image_text']."</p>";
echo "</div>";
}
?>
<form method="POST" action="test.php" enctype="multipart/form-data">
<input type="hidden" name="size" value="1000000">
<div>
<input type="file" name="image" style="width: 215px">
</div>
<div>
<input type="text" id="text" name="image_text" placeholder="Enter Your Name" style="width: 125px"> </div>
<div>
<button type="submit" name="upload">POST</button>
</div>
</form>
</div>
</body>
</html>
Add logging so that you can trace through what happens.