使用从 Flex Air 应用程序接收的 php 保存字节数组 [英] Saving a bytearray with php received from Flex Air app

查看:22
本文介绍了使用从 Flex Air 应用程序接收的 php 保存字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 codeigniter 中有一个带有远程服务的 Air 应用程序.我正在尝试保存从 Air 应用程序收到的字节数组但是当我保存数据时,我得到了文件名正确的空文件.

I have an Air application with remote service in codeigniter. I'm trying to save a bytearray that I received from the Air app but when I save the data I get empty files with the correct filename.

所以我的字节数组或我保存数据的方式一定有问题.有谁知道我做错了什么?我已经调试了我发送的 Arraycollection 并且 bytearray 肯定在那里.

So there must be something wrong with my bytearray or the way I save the data. Does anyone have an idea what I'm doing wrong? I've debugged the Arraycollection I sent and the bytearray is definitely in there.

public function uploadImage($image)
{

    foreach($image as $img)
    {

        $file = $img['name'];
        $data = new ByteArray($img['bytes']);

        file_put_contents( $_SERVER['DOCUMENT_ROOT'] . '/uploads/test/' .$file, $data);

    }

}

推荐答案

好的,对于那些对解决方案感兴趣的人,显然我只需要更改此 $data = new ByteArray($img['bytes']); 到这个 $data = $img['bytes']->data;

Ok for those who are interested in the solution, aparrently I just had to change this $data = new ByteArray($img['bytes']); into this $data = $img['bytes’]->data;

这篇关于使用从 Flex Air 应用程序接收的 php 保存字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆