顯示具有 PHP相關 標籤的文章。 顯示所有文章
顯示具有 PHP相關 標籤的文章。 顯示所有文章

Flash 編輯 XML By PHP

首先要記得設定 php.ini

開啟php.ini,搜尋
;always_populate_raw_post_data = On
然後把前面的;拿掉變成
always_populate_raw_post_data = On
存檔 重啟server

AS3的部分


















 

 

PHP的部分
<?
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
    $xml = $GLOBALS["HTTP_RAW_POST_DATA"];
    $file = fopen("init.xml", "wb");
    fwrite($file, $xml);
    fclose($file);
    echo($GLOBALS["HTTP_RAW_POST_DATA"]);
}
?>

PHP 呼叫Flash

div 的部分是設定Flash畫面位置 !!
還需要多做測試 ~~
<div style="position:absolute; top:50%; left:50%; margin-left:-450px; margin-top:-215px;> width:900px; height:430px;"/>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="FdoStory" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="檔案名稱" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="檔案名稱" quality="high" bgcolor="aqua" width="100%" height="100%" name="檔名" align="middle" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_tw" />
</object>
</div>

Flash & PHP 的檔案上傳

利用 FileReference 可以製作檔案上傳

AS3:


package {
    import flash.display.MovieClip;

    import flash.display.Sprite;
    import flash.errors.IOError;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    import flash.text.TextField;

    public class Main extends Sprite {
        private var file:FileReference = new FileReference;
        private var _Text:TextField = new TextField;

        public function Main():void {
            if (stage)
                init();
            else
                addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            _Text.text = "執行資訊";
            this.addChild(_Text) ;

          
            //Box為一個 MovieClip
            var box:Box = new Box;
            this.addChild(box);
            box.y = 100;

            box.addEventListener(MouseEvent.CLICK, box_click)
        }

        private function box_click(event:MouseEvent):void {
            trace ("選擇檔案") ;
            _Text.text = "選擇檔案" ;
            file.browse();
            file.addEventListener(Event.SELECT, file_select);
            file.addEventListener(IOErrorEvent.IO_ERROR, file_ioError);
            file.addEventListener(Event.COMPLETE, file_complete) ;
            file.addEventListener(Event.OPEN , file_open) ;           
        }

        private function file_select(event:Event):void {
            var temp_url:URLRequest = new URLRequest;
            //PHP的檔案位置
            temp_url.url = './php_file9.php'
            file.upload(temp_url);
        }

        private function file_ioError(event:IOErrorEvent):void {
            _Text.text = '傳送失敗';
        }
      
        private function file_complete(event:Event):void {
            _Text.text = '傳送成功' ;
            }
          
        private function file_open(event:Event):void {
            _Text.text = '開始傳送' ;
            }
    }
}


PHP:
  if (is_uploaded_file($_FILES['Filedata']['tmp_name']))   {

    $uploadDirectory = "uploads/";
    $uploadFile = $uploadDirectory . basename($_FILES['Filedata']['name']);

    copy($_FILES['Filedata']['tmp_name'], $uploadFile);
  }
?>