0

I have problem displaying my image after I upload my coding to online web hosting. When I do in my localhost, I the image manage to retrieve out and manage to move to the accessory folder. But when I try in online, the image upload do not move to the accessory folder that store the image and cannot be retrieve out. Below is my code:

adminadd.php

<?php 
session_start();
$connect = mysqli_connect("localhost", "root", "", "db_name");

if(isset($_POST['submit'])){
    $name=$_POST['name'];
    $description=$_POST['description'];
    $image = $_FILES['image']['name'];
    $image_temp = $_FILES['image']['tmp_name'];
    move_uploaded_file($image_temp,"accessory/".$image);
    $price=$_POST['price'];
    $category=$_POST['category'];

    $query="INSERT INTO product (name,product_description,price,catid,image) VALUES ('$name','$description','$price','$category','$image')";

    if(mysqli_query($connect, $query)){
        echo "<script>alert('Successfully inserted')</script>";

    }
}
?>

Can someone enlighten me with my problem. Appreciate alot.

1 Answers1

2

The destination needs to be a filename, not a URL.

Typically, it is not possible to write to HTTP URLs (it requires the server to be set up to allow it, and for you to make a PUT request with appropriate authentication … move_uploaded_file can't do that).

Change http://fypesystem.com/Shineacc/accessory/ to a directory path on your server's filesystem.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Directory path like how? Can you show me example please. –  Dec 09 '17 at 14:22
  • If your site hosted on linux you could simply do : move_uploaded_file($image_temp, '/var/www/html/Shineacc/accessory/'.$image); make sure to replace the example path with yours – Amila K. Dec 09 '17 at 14:25
  • Directory paths do not start with `http://` not do they include hostnames! – Quentin Dec 09 '17 at 14:25