通过$ _POST导致文件上载错误

时间:2011-03-01 08:41:55

标签: php flash post

我尝试从我的Flashfile中捕获文件上载,这会将$ _POST发送到我的文件upload.php。

也许有人发现我的Bug,文件没有上传。

$data = $GLOBALS["HTTP_RAW_POST_DATA"];
$fp = fopen("upload/".$session."/".$wkid."/".$data, "wb");
fwrite($fp, $data);
fclose($fp);

POST的标题如下:

http://192.168.1.161:81/upload.php

POST /upload.php HTTP/1.1
Host: 192.168.1.161:81
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: PHPSESSID=9873ceb6399eafefb91dac3b942d0b78; __utma=48168551.1670897330.1298964838.1298964838.1298968544.2; __utmc=48168551; __utmz=48168551.1298964838.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); phpMyAdmin=f54c4ad7eb21706a57b4b6e5058dd2cfbea1cc32; pma_lang=de-utf-8; pma_charset=utf-8; pma_mcrypt_iv=UX8VuU94d%2BA%3D; pmaUser-1=SNAWkCqwJCg%3D; pmaPass-1=eV3KOmsoVPlmV1Z%2BYkskZQ%3D%3D; pma_fontsize=82%25; pma_theme=original; __utmb=48168551.2.10.1298968544; session=9873ceb6399eafefb91dac3b942d0b78; wkid=314; uid=25c75688b1e929d494fea85a0d6a8439
Referer: http://192.168.1.161:81/upload.swf
Content-type: application/octet-stream
Content-length: 73371

PNG


HTTP/1.1 200 OK
Date: Tue, 01 Mar 2011 08:35:03 GMT
Server: Apache/2.2.9
X-Powered-By: PHP/5.2.6-1+lenny9
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 35
Keep-Alive: timeout=3, max=100
Connection: Keep-Alive
Content-Type: text/html

此致

2 个答案:

答案 0 :(得分:1)

您应尝试使用以下方式阅读原始帖子数据:

$data = file_get_contents("php://input");

答案 1 :(得分:0)

我认为这个问题可能就是这个问题:

$fp = fopen("upload/".$session."/".$wkid."/".$data, "wb");

$data已设置为原始POST有效内容。通过这个fopen调用,您正在尝试使用其名称中的原始字节流(可能超过10K)创建一个文件名。虽然这取决于实际的文件系统,但它很可能在大多数BSD / Linux服务器上失败。