Jump to content

PHP problem with local files


Recommended Posts

Dear all,

I am working on an embedded Linux platform with Lighttpd and PHP-7.0.
My goal is using some HTML button and sliders to write some values on a local file.

For example, if I click on a HTML button, I want to create and write a text file located in /home/$USER/
To do that, I build some files


<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">

<form action="test1.php" method="POST">
    <input type="submit" value="Open Script">


    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);

    exec("/bin/bash /var/www/html/test.sh");



cd /home/$USER/
touch testFile && echo "This is a test" > testFile

So, when I launch the Shell Script like this:

cd /var/www/html

It works fine, and when I launch the PHP script like this:

cd /var/www/html
php test1.php

It works also.

My problem is when I want to launch it through the webpage...it doesn't works.
I think because I have some wrong permissions, so I did this:

sudo usermod -a -G www-data $USER
sudo chgrp -R www-data /var/www/html
sudo chmod -R g+w /var/www/html

But no luck, I still doesn't work.

Do you have an idea of the problem ?

Thanks for your help and support.


Edited by cherault
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...