Hi,
I was doing a compilation of c file in wamp server
I use
if ((move_uploaded_file($_FILES['compiledfile']['tmp_name'], $newname))) {
$source = 'upload\\' . $_FILES['compiledfile']['name'];
//echo $source;
$destination = 'upload\\' . pathinfo($_FILES['compiledfile']['name'], PATHINFO_FILENAME) . '.exe';
//echo $destination;
$output = system('"C:\Program Files\CodeBlocks\MinGW\bin\gcc.exe" ' . $source . ' -O3 -o ' . $destination);
echo $output;
which has been working correctly.
I decided to migrate to an ubuntu server
I have installed all the component from apache, php, mysql, and phpmyadmin.
I also install a codeblock for gcc compiler.
Then I try to correct the path as ubuntu use / not \ like windows.
However, I can't find what is wrong.
Below is my code
if ((move_uploaded_file($_FILES['compiledfile']['tmp_name'], $newname))) {
$source = 'upload\\' . $_FILES['compiledfile']['name'];
//echo $source;
$destination = 'upload\\' . pathinfo($_FILES['compiledfile']['name'], PATHINFO_FILENAME) . '.exe';
//echo $destination;
$output = system('"/usr/bin/gcc-4.5.executable" ' . $source . ' -O3 -o ' . $destination);
echo $output;
I already set the permission from root so I can create and delete the file inside the bin folder (where gcc is installed) and do the same thing for the upload folder inside my webroot.
What am I missing?
I try using $returnvalue after the command string
$output = system('"/usr/bin/gcc-4.5.executable" ' . $source . ' -O3 -o ' . $destination,$returnvalue);
echo $output;
echo $returnvalue;
However, the output if I upload a syntax error file is 1 which is not helping me to know what is the problem. How can I output the text error that usually appear under your command in the ubuntu terminal or windows command line in order to know what is wrong with my $output?
Thanks in advance๐