Flex命令问题

时间:2012-04-18 13:05:24

标签: php linux flex

我在将.css文件转换为.swf时遇到问题,如果我通过shell运行flex commad它正在运行,但不幸的是通过php它无法正常工作。

<?php
    $tm = time();
    $file_n = $_FILES["file"]["name"];
    $path = "";
    if ($_FILES["file"]["type"] == "text/css") {
        if ($_FILES["file"]["error"] > 0) {
            return "Error has occured: " . $_FILES["file"]["error"] . "<br />";
        }
        else
        {
            if (file_exists("upload/" . $_FILES["file"]["name"])) {
                move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $tm . "_" . $file_n);
                $path = "upload/" . $tm . "_" . $file_n;
            }
            else
            {
                move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
                $path = "upload/" . $file_n;
            }
        }

        $paths = explode(".", $path);
        exec("mxmlc ".$file_n);
        $parr = array('path' => $paths[0].".swf");
        $jurl = json_encode($parr);
        echo $jurl;
    }
    else
    {
        echo "Sorry not supported file type!";
    }
    ?>

1 个答案:

答案 0 :(得分:0)

这是正确的答案,因为它在我的情况下是正确的: 我使用 shell_exec 而不是 exec 并添加命令的路径

<?php
require_once("md5prefix.php");
$file_n = $_FILES["file"]["name"];
$tm = generatePassword(8);
$path = "";
if ($_FILES["file"]["type"] == "text/css") {
    if ($_FILES["file"]["error"] > 0) {
        return "Error has occured: " . $_FILES["file"]["error"] . "<br />";
    }
    else
    {
        if (file_exists("upload/" . $_FILES["file"]["name"])) {
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $tm . "_" . $file_n);
            $path = "upload/" . $tm . "_" . $file_n;
        }
        else
        {
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
            $path = "upload/" . $file_n;
        }
    }
    $paths = explode(".", $path);
    $output = shell_exec('/home/flexer/flex_sdk_4.6/bin/mxmlc ' . $path); 
    $parr = array('path' => $paths[0].".swf");
    $jurl = json_encode($parr);
    echo $jurl;
}
else
{
    echo "Sorry not supported file type!";
}
?>