简体   繁体   English

尝试使用$ GLOBALS [“ HTTP_RAW_POST_DATA”]将文件从Flash保存到PHP

[英]Trying to save file from Flash to PHP using $GLOBALS[“HTTP_RAW_POST_DATA”]

Let me start by saying PHP isn't my forte, I'm usually reluctant to try working with it because of problems exactly like this. 首先,我要说PHP不是我的强项,由于类似这样的问题,我通常不愿意尝试使用它。 The code works fine on my local machine under MAMP and on my server, but doesn't on the clients server :'( 该代码在MAMP下的本地计算机上和服务器上都可以正常运行,但在客户端服务器上却不起作用:'(

So what am I trying to do, well - save an image from Flash onto the server, simple right?! 那我想做什么呢-将Flash中的图像保存到服务器上,简单吧?!

I'm using the method described on this site here: http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/ but have made a small alteration so that instead of echoing the jpg causing the browser to download it locally, I do an fwrite and an fclose to save it to the server. 我使用的是此网站上描述的方法: http : //designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/,但做了一些小的改动,以代替回显jpg,导致浏览器将其下载到本地,我执行了fwrite和fclose将其保存到服务器。

Here is my PHP: 这是我的PHP:

I've dona a phpinfo() on my clients server and it's running 5.2.2 my host is running 5.2.11 I don't know if much can have changed in those 9 minor revisions? 我在客户端服务器上安装了一个phpinfo(),它正在运行5.2.2我的主机正在运行5.2.11我不知道在这9个较小的修订版中是否可以进行很多更改?

I've also read another question on here which suggests making suer always_populate_raw_post_data is set to ON, but it's set to OFF on all of the server environments I've been testing in. I'm doing some XML saving using file_get_contents('php://input') which I've tried but failed to get working with images. 我还在这里阅读了另一个问题,该问题建议将suer always_populate_raw_post_data设置为ON,但是在我一直在测试的所有服务器环境中将其设置为OFF。我正在使用file_get_contents('php: // input'),我尝试过但无法使用图片。

Any help would be gratefully received, I'm happy to post the AS3 as well but it's EXACTLY the same as example I've linked above and works locally. 我们将不胜感激地收到任何帮助,我也很高兴发布AS3,但它与我上面链接的示例完全相同,并且可以在本地工作。 As far as I can tell the problem lies with the PHP. 据我所知,问题出在PHP。

Cheers. 干杯。

Is there any reason you're using the HTTP_RAW_POST_DATA? 您使用HTTP_RAW_POST_DATA有什么原因吗? If Flash is sending the file via the POST method, it'd be by far easier to use the $_FILES array. 如果Flash通过POST方法发送文件,则使用$_FILES数组要容易得多。 There'd be no need to fopen/fwrite, as the file's already been stuck into a temp dir by PHP. 无需进行fopen / fwrite操作,因为该文件已经被PHP卡入了temp目录中。 All you have to do is use [move_uploaded_file()][1] to put it wherever you want on the server. 您所要做的就是使用[move_uploaded_file()][1]将其放在服务器上的任何位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM