Skip to content
Advertisement

User’s cant upload images on published website

I have a website which you can upload pictures and see them. I was uploading and gettin pictures with no problem on localhost but after publishing with freewebhostingarea i get these errors.

Warning: move_uploaded_file(img/pexels-garvin-st-villier-3874337.jpg): failed to open stream: Permission denied in /home/vhosts/jdm-sepeti.eu5.org/addCarF.php on line 22

Warning: move_uploaded_file(): Unable to move ‘/tmp/phpHdU7FE’ to ‘img/pexels-garvin-st-villier-3874337.jpg’ in /home/vhosts/jdm-sepeti.eu5.org/addCarF.php on line 22

This is how i upload images on php:

$target = "img/" . basename($_FILES['image']['name']);
$fileType = pathinfo($target, PATHINFO_EXTENSION);
 $allowTypes = array('jpg', 'png');
    if (in_array($fileType, $allowTypes)) {
        if (move_uploaded_file($_FILES["image"]["tmp_name"], $target))...

I’m using the phpmyadmin that freewebhosting provides. I’would be glad if anyone can help. Thanks.

Advertisement

Answer

try to change the directory chmod permission to 0777. 🙂

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement