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

发布于 2024-08-28 15:35:54 字数 823 浏览 2 评论 0原文

首先我要说的是 PHP 不是我的强项,我通常不愿意尝试使用它,因为正是这样的问题。该代码在我的 MAMP 下的本地计算机和我的服务器上运行良好,但在客户端服务器上运行不佳:'(

那么我想做什么,好吧 - 将图像从 Flash 保存到服务器上,很简单吧?!

我正在使用本网站上描述的方法: http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed- saving-images-from-flash/ 但做了一个小改动,这样就不会回显 jpg 导致浏览器要在本地下载它,我执行 fwrite 和 fclose 将其保存到服务器,

这是我的 PHP:

我在客户端服务器上运行了 phpinfo(),它正在运行 5.2.2 我的主机正在运行 5.2.11 我不知道这 9 个小修订是否可以进行很多更改?

我还在这里阅读了另一个问题,该问题建议将 suer always_populate_raw_post_data 设置为 ON,但在我测试过的所有服务器环境上将其设置为 OFF我正在使用 file_get_contents('php://input') 进行一些 XML 保存,我已经尝试过但未能处理图像。

如有任何帮助,我们将不胜感激,我也很高兴发布 AS3,但它与我上面链接的示例完全相同,并且可以在本地运行。据我所知,问题出在 PHP 上。

干杯。

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. The code works fine on my local machine under MAMP and on my server, but doesn't on the clients server :'(

So what am I trying to do, well - save an image from Flash onto the server, simple right?!

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.

Here is my 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?

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.

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. As far as I can tell the problem lies with the PHP.

Cheers.

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

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

发布评论

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

评论(1

我也只是我 2024-09-04 15:35:54

您使用 HTTP_RAW_POST_DATA 有什么原因吗?如果 Flash 通过 POST 方法发送文件,那么使用 $_FILES 数组会容易得多。无需 fopen/fwrite,因为该文件已被 PHP 粘贴到临时目录中。您所要做的就是使用 [move_uploaded_file()][1] 将其放置在服务器上您想要的任何位置。

Is there any reason you're using the 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. There'd be no need to fopen/fwrite, as the file's already been stuck into a temp dir by PHP. All you have to do is use [move_uploaded_file()][1] to put it wherever you want on the server.

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