Compiling swf from php using mxmlc and “exec” - loading config file but no swf in browser

人走茶凉 提交于 2019-12-11 06:21:04

问题


I'm on a RedHat server, with a simple PHP page that has a form, with inputs for name, phone, and url.

When the form is submitted, I run a command to compile a swf using mxmlc. The command is this :

$generate_command1 = "export _JAVA_OPTIONS=\"-Xms32m -Xmx64m\"; /opt/flex/bin/mxmlc -define+=NAMES::Name,\"\'$name\'\" -define+=NAMES::Phone,\"\'$phone\'\" -define+=NAMES::Website,\"\'$url\'\" -output /path/to/my/webserver/httpdocs/swfbuilder/generated.swf DynamicTextTest.as";

$last_line = exec($generate_command1, $out);
print_r($last_line);

The result is always :

Loading configuration file /opt/flex/frameworks/flex-config.xml

When I run the same command from ssh into the server, I actually get a swf generated. I.e.

Picked up _JAVA_OPTIONS: -Xms32m -Xmx64m
Loading configuration file /opt/flex/frameworks/flex-config.xml
/var/www/vhosts/tag.domandtom.com/httpdocs/swfbuilder/generated.swf (945 bytes)
[root@htmlfive swfbuilder]# 

Both directory and files have been CHOWN'd for ownership and CHMOD'd for 775... So what am I doing wrong to get this to work from the web page? Should I have a forked process and wait until it's complete? Sleep?

EDIT:

I've looked into fcsh and other mxmlc / java related questions.


回答1:


In re-reviewing the code, I noticed that I shouldn't have escaped the single-quotes. They're valid for the actual execution and I should only escape DOUBLE quotes for php in this instance...

The final code looks like this (for future reference) :

<?php 
$name = "generated";
$phone = "";
$url = "";

if(isset($_POST['name'])) {
    $name = $_POST['name'];
}
if(isset($_POST['phone'])) {
    $phone = $_POST['phone'];
}
if(isset($_POST['url'])) {
    $url = $_POST['url'];
}

$swfname = $name . ".swf";

$generate_command1 = "export _JAVA_OPTIONS=\"-Xms32m -Xmx64m\"; /opt/flex/bin/mxmlc -define+=NAMES::Name,\"'$name'\" -define+=NAMES::Phone,\"'$phone'\" -define+=NAMES::Website,\"'$url'\" -output /path/to/my/webserver/httpdocs/swfbuilder/$swfname DynamicTextTest.as";

exec($generate_command1, $out);
?>


来源:https://stackoverflow.com/questions/6902713/compiling-swf-from-php-using-mxmlc-and-exec-loading-config-file-but-no-swf-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!