Monday 22 January 2018

fopen - Permission denied error in php when try to write in a txt file

I'm trying to write in a txt file the data i get from a
html form, but I get this error: Warning: fopen(/var/www/4/datos.txt): failed to open
stream: Permission denied in /var/www/4/ComprobacionFormulario.php on line 13 Warning:
fwrite() expects parameter 1 to be resource, boolean given in
/var/www/4/ComprobacionFormulario.php on line 16 Warning: fclose() expects parameter 1
to be resource, boolean given in /var/www/4/ComprobacionFormulario.php on line
17



'datos.txt' Is the file where i'm trying to
write. Here is my php
code:




error_reporting(E_ALL);
ini_set('display_errors',
true);

$des=$_POST['description'];
$cant=$_POST['quantity'];
$prec=$_POST['price'];
$nombrearchivo="datos.txt";
$content="Description:
$des\tQuantity: $cant\tPrice: $prec\n";
$handle=fopen($nombrearchivo,
'w');


fwrite($handle,
$content);
fclose($handle);

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...