I have a simple .php file:
<?php
$archivo = $_POST["name"];
$alineamiento = $_POST["alineamiento"];
$fp=fopen("$archivo","w");
fwrite($fp,$alineamiento);
fclose($fp);
?>
This works fine, but when I need to write the file in a subfolder (sub_mat):
<?php
$archivo = $_POST["name"];
$alineamiento = $_POST["alineamiento"];
$fp=fopen("/var/www/SChip/sub_mat/$archivo","w");
fwrite($fp,$alineamiento);
fclose($fp);
?>
this doesn't work. I also try it without the absolute path dir, like:
<?php
$archivo = $_POST["name"];
$alineamiento = $_POST["alineamiento"];
$fp=fopen("sub_mat/$archivo","w");
fwrite($fp,$alineamiento);
fclose($fp);
?>
I have rw
permissions in the sub_mat folder. I try this with Chrome, FF, and Opera, and it doesn't work. I know this must be silly but I can't figure out the problem.
EDIT
I modified the script, adding system("mv ...")
and initializing the values.
If I run this in the Console it works fine, no errors, only:
PHP Notice: Undefined index: name in /var/www/SChip/create-matrix.php on line 2
PHP Notice: Undefined index: alineamiento in /var/www/SChip/create-matrix.php on line 3
but that's obvious... But when I run in Chrome or FF it doesn't work, no errors or warnings. It just leaves the file in the current folder, and the mv
is not executed.
<?php
$archivo = $_POST["name"];
$alineamiento = $_POST["alineamiento"];
$archivo = "testing";
$alineamiento = "test2";
$fp=fopen("$archivo","w");
fwrite($fp,$alineamiento);
fclose($fp);
system("mv $archivo custom_matrices_temporal/$archivo");
?>
The directory needs execute (x
) permissions as well to allow the creation of new files.