hi.
i have a html form that allows user to browse and upload the code using the upload button ( which runs php). the files gets uploaded. now i need to either change that existing php file or add a new button in html file and compile and run the code that was uploaded and display its result.

the project is to develop online app. that can take the c++ code of students and upload it and allow uploded code to compile and run.

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"] . " <br />";

  echo "<p /><p />SOURCE: ".$_FILES["file"]["tmp_name"]."<br />";
  echo "DEST: "."/var/www/C275/tmp/"."TESTFILENAME"."<br /><p />";

  $success = move_uploaded_file($_FILES["file"]["tmp_name"] ,
                                         "/var/www/C275/tmp/" . "TESTFILENAME");

  if($success)
    echo "Success<br />";
  else
    echo "FAILURE! <br />";

  }
?>

Recommended Answers

All 2 Replies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.