0

我在将 .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!";
    }
    ?>
4

1 回答 1

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!";
}
?>
于 2012-04-19T13:30:50.117 回答