0

i run this code to upload an image and it works perfectly on wampserver but when ever i test it on the hosted site it doesn't work, i activated the error reporting and there is no error but still no image uploaded, please if it is a permission issue on the server tell me how to fix it. thanks

    if(isset($_POST['submit']) === true) {  

            $newname  =  "hello.jpg";
        $location = 'img/products_img/';
        move_uploaded_file($_FILES['image']['tmp_name'],$location.$newname);

        }

and the form code is :

<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="image" /> <br />
<input type="submit" name="submit" value="Upload Image" />
</form>

1 Answers1

0

Make sure that the target folder is writable by apache

chmod 755 img/products_img/

chown apache:apache img/products_img/

tchow002
  • 1,068
  • 6
  • 8