使用POST方法将数据从Flash发送到PHP

发布于 2024-11-09 10:28:31 字数 374 浏览 0 评论 0原文

我开发了一个应用程序,允许用户在画布上绘制简单的图像。影片剪辑(画布)的名称是canvas_mc。

我需要使用 php 将这张图保存在服务器上。我必须将影片剪辑(canvas_mc)转换为png和jpeg并保存。我已使用 http://www.flashandmath 中提供的一些类成功将其保存在本地驱动器上

。 com/advanced/smoothdraw/index.html

如何使用 PHP 将其保存在服务器上。我被要求使用 post 方法。如果可能的话,也给我代码,因为我刚刚从设计转向编程:-)

I have a developed a application that allows users to draw simple images on a canvas. The name of the movieclip(canvas) is canvas_mc.

I need to save this drawing on the server using php. I have to convert the movieclip (canvas_mc) into png and jpeg and save it. I have successfully save it on local drive using some classes available in

http://www.flashandmath.com/advanced/smoothdraw/index.html

How can I save it on server using PHP. I have been asked to use the post method. If possible give me the code also as I just moved into programming from design :-)

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

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

发布评论

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

评论(1

暗恋未遂 2024-11-16 10:28:32

不确定如何将图像转换为数据等,但我有一个类,您可以使用它将数据传输到 PHP 脚本(可以从那里将数据插入数据库)。

package
{
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.net.URLVariables;
    import flash.net.URLRequestMethod;
    import flash.events.Event;

    /**
     * @author Marty Wallace
     * @version 1.00
     */
    public class PHPData extends Object
    {
        /**
         * Sends data to a PHP script
         * @param script A URL to the PHP script
         */
        public function send(script:String, vars:URLVariables):void
        {
            var req:URLRequest = new URLRequest(script);

            req.data = vars;
            req.method = URLRequestMethod.POST;

            var loader:URLLoader = new URLLoader();
            loader.load(req);

            // listeners
            loader.addEventListener(Event.COMPLETE, _complete);
        }

        /**
         * Called when a response has been received from a PHP script
         * @param e Event.COMPLETE
         */
        private function _complete(e:Event):void
        {
            var vars:URLVariables = new URLVariables(e.target.data);

            var i:String;
            for(i in vars)
            {
                trace(i + ": " + vars[i]);
            }

            e.target.removeEventListener(Event.COMPLETE, _complete);
        }
    }
}

使用:

var php:PHPData = new PHPData();
var vars:URLVariables = new URLVariables();

vars.imagedata = your_image_data;

php.send("your_php_script.php", vars);

Not sure about how to convert your image into data and such, but here's a class I have lying around that you can use to transfer data to a PHP script (which can from there insert the data into a database).

package
{
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.net.URLVariables;
    import flash.net.URLRequestMethod;
    import flash.events.Event;

    /**
     * @author Marty Wallace
     * @version 1.00
     */
    public class PHPData extends Object
    {
        /**
         * Sends data to a PHP script
         * @param script A URL to the PHP script
         */
        public function send(script:String, vars:URLVariables):void
        {
            var req:URLRequest = new URLRequest(script);

            req.data = vars;
            req.method = URLRequestMethod.POST;

            var loader:URLLoader = new URLLoader();
            loader.load(req);

            // listeners
            loader.addEventListener(Event.COMPLETE, _complete);
        }

        /**
         * Called when a response has been received from a PHP script
         * @param e Event.COMPLETE
         */
        private function _complete(e:Event):void
        {
            var vars:URLVariables = new URLVariables(e.target.data);

            var i:String;
            for(i in vars)
            {
                trace(i + ": " + vars[i]);
            }

            e.target.removeEventListener(Event.COMPLETE, _complete);
        }
    }
}

Use:

var php:PHPData = new PHPData();
var vars:URLVariables = new URLVariables();

vars.imagedata = your_image_data;

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