将上传文件从PHP移动到CGI

Im trying to pass post file information to an upload.php file and have that information be sent to a CGI script. There is nothing on the net on how to go about doing this that i can find, iv spent days. I know there are a few people out there that need this, it could help us all that have legacy perl scripts.

Dataflow:
Jquery --> Upload.php --> index.cgi

My php:

<?php
if(isset($_FILES['file'])) {  

if(move_uploaded_file($_FILES['file']['tmp_name'], "../index.cgi" . $_FILES['file']['name'])){  

            echo "success";  

           exit;  
}  
}  
?>

Post call to CGI example:

foobar.com/index.cgi?act=store&data=$filename

Any suggestions would help greatly. Thank you.

From my understanding, your CGI script is receiving a parameter which is the path of the uploaded script. However you are attempting to pass the uploaded script to your CGI script using a function that is only supposed to move a file from 1 place to another without executing a script. my suggestion is to do the following

<?php
if(isset($_FILES['file'])) {  
    $destination = "new/path/to/".$_FILES['file']['name'];
    if(move_uploaded_file($_FILES['file']['tmp_name'], $destination)){  

        $data = array();
        //You can add multiple post parameters here
        //$data = array('param1' => 'value1', 'param2' => 'value2');
        $url = "http://url/to/hello.cgi";
        // You can POST a file by prefixing with an @ (for <input type="file"> fields)
        $data['file'] = '@'.$destination;

        $handle = curl_init($url);
        curl_setopt($handle, CURLOPT_POST, true);
        curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
        $result = curl_exec($handle);
        if($result) {
           echo "success";
        }    
         exit;  
    }  
}  

?>

You can execute the cgi script via a CURL POST and pass any params you want