skip to Main Content

I have a website powered by php on centos 7 and this website has methods for upload and delete file in the centos’ "/var/www/html/uploadfile" directory. PHP’s "move_uploaded_file" method and "unlink" method was not working before but I connecting centos with ssh and i write in terminal:

chcon -R -t httpd_sys_rw_content_t /var/www/html/uploadfile

sudo chmod -R 777 /var/www/html/uploadfile

chmod a+rwxt /tmp /var/www/html/uploadfile

and "move_uploaded_file" method is working succesful now. But "unlink" method still not working.

I will say one more thing, "uploadfile" folder’s owner is root, but uploaded file’s owner is apache. Could it be because of this situation?

enter image description here

(This methods was working succesfully in my localhost. I think my problem is about centos’s file-permissions.)

2

Answers


  1. Chosen as BEST ANSWER

    Ok fine, my code:

    <?php include "dbbaglanti.php" ?>
    <?php
    
        $silinecekice=$_POST['silinecekice'];
        $sorgu2=mysqli_query($baglan, "SELECT kurs_id, ice_link, kursici_index  FROM icerik WHERE ice_index=$silinecekice");
        $sorgu2info=mysqli_fetch_array($sorgu2);
        $kursid=$sorgu2info['kurs_id'];
        $icelink=$sorgu2info['ice_link'];
        $kursiciindex=$sorgu2info['kursici_index'];
    
        unlink("$icelink"); //unlink(uploadfile/xxx.mp4);
    
        $biticesil=mysqli_query($baglan, "DELETE FROM bitirilenicerik WHERE ice_id='$silinecekice'");
        $sorgu=mysqli_query($baglan,"DELETE FROM icerik WHERE ice_index='$silinecekice'");
        header("location: kursuyonet.php");
        mysqli_close($baglan);
    ?>
    

    And I say it again; I'm sure the problem isn't in my code. Because this code working succesfully in my localhost. I think this problem is indeed with file perms.


  2. put your code to check it

    without your code nobody can solve your problem

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search