使用php更具体地从HTTP_RAW_POST_DATA上传flash中的图像?

时间:2010-08-04 15:10:05

标签: php flash upload directory

我目前正在使用它,因此它会显示一个对话框,用于将图像保存到您的计算机上:

if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{

// get bytearray
$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];

// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
    echo $jpg;
}

只是想知道是否有办法将文件直接放入目录/文件而不需要对话框?

喜欢上传者?

2 个答案:

答案 0 :(得分:1)

不,没有。

答案 1 :(得分:0)

只需阅读页面内容并使用fopen,fwrite e.t.c保存到文件中。

if (isset($GLOBALS["HTTP_RAW_POST_DATA"])){

    // get bytearray
    $jpg = $GLOBALS["HTTP_RAW_POST_DATA"];

    // add headers for download dialog-box
 ob_start();
    header('Content-Type: image/jpeg');
       echo $jpg;
  $image=ob_get_clean();
   //and here write it into file      
  }

以下是我的代码,您可以删除对您无用的不必要的东西

 if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] ))     {
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
$filename=$_GET['name'];
$fullFilePath='files/'.$filename;
$handle=fopen($fullFilePath,"w");
fwrite($handle,$im);
fclose($handle);
$returnVars = array();
$returnVars['write'] = "yes";
$returnString = http_build_query($returnVars);
//send variables back to Flash
echo $returnString;
  }