Flex 项目发布时运行 PHP 文件的问题

发布于 2024-10-18 20:52:19 字数 1511 浏览 1 评论 0原文

问题:

我使用 HTTPService 调用 PHP 文件。我将此 HTTPService 的结果设置为一个函数,该函数用 PHP 文件返回(回显)的任何内容填充 testTextArea。当我从 flash builder 运行应用程序时,这工作正常,即我在 testTextArea 中得到字符串,并由我的 PHP 文件回显。但是,当我发布项目并且 testTextArea 被 PHP 文件的整个代码填充时,这不能正常工作。

代码:

     private function addUserServiceHandler(event:ResultEvent):void{
            testTextArea.text = event.result.toString(); //This outputs the whole php file in to the textArea as if it were a string
        }


        private function saveButtonClicked():void{
            addUserService.send();
        }

    ]]>
</fx:Script>

<fx:Declarations>
    <mx:HTTPService id="addUserService" url="addUser.php" resultFormat="text" method="POST" result="addUserServiceHandler(event)" >
        <mx:request xmlns="">
            <firstName>{firstNameTextInput.text}</firstName>
            <lastName>{lastNameTextInput.text}</lastName>
            <imageName>{uploadTextInput.text}</imageName>
            <adultContent>{adultContentRadioGroup.selectedValue}</adultContent>
            <p2p>{p2pRadioGroup.selectedValue}</p2p>
            <priority>{priorityRadioGroup.selectedValue}</priority>
        </mx:request>
    </mx:HTTPService>
<fx:Declarations>



<s:Button id="saveButton" includeIn="AddUser" x="313" y="128" label="Save" width="187" height="33" click="saveButtonClicked()"/>

Problem:

I call a PHP file using an HTTPService. I set the result of this HTTPService to a function which populates a testTextArea with whatever the PHP file has returned (echoed). This work fine when I run the application from flash builder i.e. I get strings in the testTextArea, echoed by my PHP file. But this does not work fine when I make the Release of the project and the testTextArea gets populated by the whole code of PHP file.

Code:

     private function addUserServiceHandler(event:ResultEvent):void{
            testTextArea.text = event.result.toString(); //This outputs the whole php file in to the textArea as if it were a string
        }


        private function saveButtonClicked():void{
            addUserService.send();
        }

    ]]>
</fx:Script>

<fx:Declarations>
    <mx:HTTPService id="addUserService" url="addUser.php" resultFormat="text" method="POST" result="addUserServiceHandler(event)" >
        <mx:request xmlns="">
            <firstName>{firstNameTextInput.text}</firstName>
            <lastName>{lastNameTextInput.text}</lastName>
            <imageName>{uploadTextInput.text}</imageName>
            <adultContent>{adultContentRadioGroup.selectedValue}</adultContent>
            <p2p>{p2pRadioGroup.selectedValue}</p2p>
            <priority>{priorityRadioGroup.selectedValue}</priority>
        </mx:request>
    </mx:HTTPService>
<fx:Declarations>



<s:Button id="saveButton" includeIn="AddUser" x="313" y="128" label="Save" width="187" height="33" click="saveButtonClicked()"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葬心 2024-10-25 20:52:19

生产服务器是否配置为提供 PHP 文件?听起来您的 Web 服务器正在将 PHP 文件作为文本文件提供服务。

将包含以下内容的 info.php 文件放在生产服务器上(与 addUser.php 位于同一目录中),

<?php
phpinfo();
?>

然后在浏览器中直接导航到该文件。如果您按原样看到上述文本,那么您将需要让 PHP 正常工作。

Is the production server configured to serve PHP files? It sounds like your web server is serving the PHP file as as text file.

Place an info.php file on your production server (in the same directory as addUser.php) with the following contents:

<?php
phpinfo();
?>

and then navigate directly to it in your browser. If you see the above text as-is, then you will need to get PHP working.

日记撕了你也走了 2024-10-25 20:52:19

问题的出现是因为我通过双击错误地从硬盘运行了我的 html 文件,即我没有使用 localhost 运行它。

The problem was arising because I was mistakenly running my html file from harddisk by double clicking it i.e. I wasn't running it with localhost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文