Flex 项目发布时运行 PHP 文件的问题
问题:
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
生产服务器是否配置为提供 PHP 文件?听起来您的 Web 服务器正在将 PHP 文件作为文本文件提供服务。
将包含以下内容的 info.php 文件放在生产服务器上(与 addUser.php 位于同一目录中),
然后在浏览器中直接导航到该文件。如果您按原样看到上述文本,那么您将需要让 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:
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.
问题的出现是因为我通过双击错误地从硬盘运行了我的 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.