1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Upload, Compile and Download C File using PHP

Discussion in 'PHP' started by bubble7, Apr 10, 2012.

  1. #1
    Hi,


    I am running a wamp server in windows.
    I am trying to compile C file which I upload and then I will try to download it.
    I can do an upload of c file.
    I also can compile if I specify the name of the c file as the source and the name of the output that I want in the code.
    I also can download it.
    However, I am currently stuck at compile.
    The code below is working
    
    $output = system('"C:\Program Files\CodeBlocks\MinGW\bin\gcc.exe" "C:\Program Files\EasyPHP-5.3.9\www\upload\test1.c" -O3 -o "C:\Program Files\EasyPHP-5.3.9\www\upload\test1.exe"');
    PHP:

    I want the file that I upload is the file that I can compile
    Hence I modify it to
    $source=dirname(__FILE__).'\upload\\'.$_FILES['uploadedfile']['name'];
    echo $source;
    //mainfilename=test1
    $outputname=substr_replace($_FILES['uploadedfile']['name'], 'exe', strpos($_FILES['uploadedfile']['name'], '.')+1);
    $destination=dirname(__FILE__).'\upload\\'.$outputname;echo $destination;         
    $output = system('"C:\Program Files\CodeBlocks\MinGW\bin\gcc.exe" $source -O3 -o $destination');
    PHP:

    $source and $destination produce the exact string as the code which is working. What am I missing to make this work?
     
    bubble7, Apr 10, 2012 IP