Hi,
I am currently using PHP on windows. I use a wamp server and codeblocks.
I already set the path from environment variable to compile a c file on cmd.
since i am very new to php so i dn't knw why my code is not working

php code

if(isset($_POST['compiler']))
{
$source=dirname(__FILE__).'/new/'.$_FILES['uploadedfile']['name'];
echo $source;
//mainfilename=test1

$outputname=substr_replace($_FILES['uploadedfile']['name'], 'exe', strpos($_FILES['uploadedfile']['name'], '.')+1);
$destination=dirname(__FILE__).'/new/'.$outputname;
echo $destination; 

    it looks to me, as if the curly bracket of the if-condition never gets closed.

    What do you want the code to do? What is the result you get? Do you have error reporting enabled?

      the code is like this

      if(isset($_POST['compiler']))
      {
      $source=dirname(__FILE__).'/new/'.$_FILES['uploadedfile']['name'];
      echo $source;
      //mainfilename=test1
      
      $outputname=substr_replace($_FILES['uploadedfile']['name'], 'exe', strpos($_FILES['uploadedfile']['name'], '.')+1);
      $destination=dirname(__FILE__).'/new/'.$outputname;
      echo $destination; 
      //$output = system('"C:\Program Files\CodeBlocks\MinGW\bin\gcc.exe" "C:\wamp\www\upload\test1.c" -O3 -o "C:\wamp\www\upload\test.exe"');
      
      $output = system('"C:\Program Files (x86)\CodeBlocks\MinGW\bin\gcc.exe" '.$source.' -O3 -o '.$destination);
      echo $output;
      }
      

      its showing error in two lines
      $source=dirname(FILE).'/new/'.$_FILES['uploadedfile']['name'];

      and
      $destination=dirname(FILE).'/new/'.$outputname;

      what should i do??

        i want the file that i uploaded to be compiled as soon as i press "compiler".. but although the file is uploaded . but it can't read file for the execution. so its exe can be created..

          When the file is uploaded it is stored in the configured temp directory under the name [font=monospace]$FILES['uploadedfile']['tmp_name'][/font].
          See the [man]_FILES[/man] manual page and the "See also:" pages linked there for more.

            Write a Reply...