使用 php 更具体地说是 HTTP_RAW_POST_DATA 从 flash 上传图像?

发布于 2024-09-13 12:34:59 字数 389 浏览 2 评论 0原文

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

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;
}

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

像上传者一样?

I currently have it working so it displays a dialogue box to save the image on your computer:

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;
}

just wondered if there is any way to put the file straight into a directory/file without the need of a dialogue box?

like an uploader?

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

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

发布评论

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

评论(2

薄荷港 2024-09-20 12:34:59

不,没有。

No, there is not.

面如桃花 2024-09-20 12:34:59

只需读取页面内容并使用 fopen 、 fwrite 等保存在文件中,

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;
  }

Just Read the content of the page and save in a file using 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      
  }

OR following is my code you can remove unneccessary things that are not useful for you

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