Jump to content
Sign in to follow this  

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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...