从Flash POST请求中读取RAW数据(图像) [英] Reading RAW data from a Flash POST Request ( images )
问题描述
我基本上正在与第三方 API flash文件进行交互,以便将HTTP POST请求发送到我的服务器。
我知道我在正确的道路上,因为它需要一个 crossdomain.xml
文件,和之前我添加的部分什么都没有在POST变量显示,但是因为我添加该文件有4变量设置,这些POST变量由应用程序发送给我关于该文件的基本信息..但我其实需要读取RAW POST数据才能真正保存Flash发送的图像。
我知道有3种方法...
$ ol
$ li $ $ c $ $ GLOBALS ['HTTP_RAW_POST_DATA']
$ HTTP_RAW_POST_DATA这可能与第一个
file_get_contents('php:// input')
无论出于何种原因,这些工作都不是。通过工作我的意思是他们没有被设置,当我var转储他们,我什么也得不到。
难道是有一个设置 php.ini
,我需要设置,或者Flash应用程序确实不发送实际的图像?我认为这样做是正确的,因为它是一个半流行的API,并被其他两个站点使用,所以我很确定它是正确的。
而且它们也不需要任何API键。
您需要在php.ini中设置 always_populate_raw_post_data = 1
来使用 HTTP_RAW_POST_DATA
(看这里)。另外,请确保您将 upload_max_filesize
设置为足够大的文件大小。
但是,HTTP_RAW_POST_DATA如果POST数据是以 multipart / form-data
的形式发送的,那么在发送文件时通常会使用它。
除非你以非标准的方式发送文件,否则你应该使用
$ _ FILES
来检索上传文件。 PHP会自动将文件上传到临时位置,并将位置放在 $ _ FILES
变量中。您可以使用 move_uploaded_file
函数将其移动到您想要的位置。例如: $ place_to_put_the_file =/my_directory/image.jpg;
if(move_uploaded_file($ _ FILES ['userfile'] ['tmp_name'],$ uploadfile)){
echo文件有效,已成功上传。
} else {
echo可能的文件上传攻击!\\\
;
}
I'm basically interacting with a third party API flash file to send HTTP POST requests to my server.
I know I'm on somewhat the right path because it requires a crossdomain.xml
file, and before I added that part nothing in the POST variables was showing up, however since I added that file there are 4 variables that are set, these POST variables are sent by the application to give me basic information about the file.. but I actually need to read the RAW POST data to actually save the image being sent by the Flash.
I'm aware there are 3 ways...
$GLOBALS['HTTP_RAW_POST_DATA']
$HTTP_RAW_POST_DATA which is probably the same as the first
file_get_contents('php://input')
For whatever reason, neither of these "work". By "work" I mean they're not being set, when I var dump them I get nothing.
Could it be that there's a setting in php.ini
that I need to set, or perhaps the Flash application is truly not sending the actual image? I think it's doing the right thing, because it's a semi popular API and it's used by a couple other sites so I'm pretty sure it's right on their end.
And they don't require any sort of API key either.
You'll need to set always_populate_raw_post_data=1
in php.ini to use HTTP_RAW_POST_DATA
(look here). Also, make sure that you set upload_max_filesize
to a value that is large enough for your files.
However, HTTP_RAW_POST_DATA will never work if the POST data is being sent as multipart/form-data
, which is usually used when sending files.
Unless you're sending files in a non-standard way, you really should be using $_FILES
to retrieve the uploads. PHP automatically saves file uploads into a temporary location and places the location in the $_FILES
variable. You can use the move_uploaded_file
function to move it to where you want it to be. For example:
$place_to_put_the_file = "/my_directory/image.jpg";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
这篇关于从Flash POST请求中读取RAW数据(图像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!