Home Backend Development PHP Tutorial Amfphp1.9 非beta版 相干情况

Amfphp1.9 非beta版 相干情况

Jun 13, 2016 am 11:03 AM
flash function gateway var

Amfphp1.9 非beta版 相关情况
1.编码问题
Fatal error: Uncaught exception 'VerboseException' with message 'Cannot modify header information
修正办法:
采用ANSI编码(这种搞起来,转换比较麻烦)或UTF8 no BOM,而非UTF8 with BOM
存为UTF8 no BOM模式:
DW参见:http://www.googlephp.cn/archives/tag/cannot-modify-header-information
DzSoft如图:
Amfphp1.9 非beta版 相干情况

另外修改根目录下gateway.php (line127):
//$gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");//注释掉,改为:
$gateway->setCharsetHandler("none", "ISO-8859-1", "ISO-8859-1");

2.NetStatusEvent
Flex/Flash 则报:
Error #2044: 未处理的 NetStatusEvent:。 level=error, code=NetConnection.Call.BadVersion
修正办法:
根目录下:
gateway.php(Line 132)

if(PRODUCTION_SERVER){//Disable profiling, remote tracing, and service browser//$gateway->disableDebug();//把它注释掉// Keep the Flash/Flex IDE player from connecting to the gateway. Used for security to stop remote connections.//$gateway->disableStandalonePlayer();//把它注释掉}
Copy after login

3.Save byteArray into Mysql with Amfphp
AS code:
package {	import flash.display.Sprite;	import flash.net.NetConnection;	import flash.net.ObjectEncoding;	import flash.net.Responder;	import flash.utils.ByteArray;	import flash.display.BitmapData;	public class Test extends Sprite	{		private var nc:NetConnection;		private var rsp:Responder;		public function Test()		{			rsp = new Responder(onResult,null);			nc = new NetConnection( );			nc.objectEncoding = ObjectEncoding.AMF3;			nc.connect("http://127.0.0.1/AmfphpForWareHouse/gateway.php");			nc.call("warehouse.MyPage.create",rsp,getData());		}		public function getData():Object		{			var obj:Object=new Object();			obj.firstName = "diding";			var bpd:BitmapData = new BitmapData(a.width,a.height);			bpd.draw(a);			var jpegEnc:JPEGEncoder = new JPEGEncoder(80);			var dat:ByteArray = jpegEnc.encode(bpd);			obj.pic = dat as ByteArray;			return obj;		}		private function onResult( e: * ):void		{			trace(e);		}	}}
Copy after login


Php Code:
<?phprequire_once "ConnectionHelper.php";class MyPage{public function create($contact){$GLOBALS['amfphp']['encoding']='amf3';$times=date("Y-m-d H:i:s");$ps1=$contact['firstName'];$ba=$contact['pic'];$data = $ba->data;$data = mysql_real_escape_string($data);$result=mysql_query("INSERT INTO userinfo (firstname,pic,addTime)VALUES ('$ps1','$data','$times')");return $result;}}?>
Copy after login


这样能存入Mysql数据库了,但在返回给flash或flex时,会出现convert报错,这时需要返回前在map(类映射)中new一下:new byteArray();
如:
<?phpclass AppVO{        var $_explicitType ="vo.AppVO";	var $id;        var $userName;        var $email;        var $phone;        var $address;        var $pic;        public function AppVO(){}	public function mapObject($obj)	{		$this->id = $obj['id'];		$this->userName = $obj['username'];		$this->email = $obj['email'];		$this->phone = $obj['phone'];		$this->address = $obj['address'];                $this->pic =new ByteArray($obj['pic']);	}}?>
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does function mean? What does function mean? Aug 04, 2023 am 10:33 AM

What does function mean?

How to solve 504 gateway timeout How to solve 504 gateway timeout Nov 27, 2023 am 10:55 AM

How to solve 504 gateway timeout

what is flash what is flash Aug 10, 2023 am 10:16 AM

what is flash

The role and examples of var keyword in PHP The role and examples of var keyword in PHP Jun 28, 2023 pm 08:58 PM

The role and examples of var keyword in PHP

18 Ways to Fix Audio Service Not Responding Issue on Windows 11 18 Ways to Fix Audio Service Not Responding Issue on Windows 11 Jun 05, 2023 pm 10:23 PM

18 Ways to Fix Audio Service Not Responding Issue on Windows 11

What is the purpose of the 'enumerate()' function in Python? What is the purpose of the 'enumerate()' function in Python? Sep 01, 2023 am 11:29 AM

What is the purpose of the 'enumerate()' function in Python?

Detailed explanation of the role and function of the MySQL.proc table Detailed explanation of the role and function of the MySQL.proc table Mar 16, 2024 am 09:03 AM

Detailed explanation of the role and function of the MySQL.proc table

Installing Flash on Debian: Detailed Guide and Sharing Linux Tips Installing Flash on Debian: Detailed Guide and Sharing Linux Tips Feb 15, 2024 pm 01:00 PM

Installing Flash on Debian: Detailed Guide and Sharing Linux Tips

See all articles