我在這裏有一個swf文件,它將通過POST將base64編碼發送到PHP。現在,我通過$ dataCode = file_get_contents(「php:// input」)獲取字符串;無法通過POST將原始數據從swf轉換爲圖像
我想實現的是通過PHP將swf編碼的base64轉換爲圖像並將其保存到特定文件夾。
這裏是我的代碼,但與此同時,我只是剝離它,看看是否imagecreatefromstring是在頁面上返回真值和輸出的圖像:
$dataCode = file_get_contents("php://input");
$dataCode = explode("=", $dataCode);
$data = $dataCode[1];
$imageData = rawurldecode($data);
$source = imagecreatefromstring($imageData);
if ($source !== false) {
header('Content-Type: image/png');
imagepng($source);
imagedestroy($source);
}
else {
echo 'An error occurred.';
}
然後在此之後,我將它保存到文件夾我會通過XML輸出圖像的URL。
事情是這樣的:
header("Content-Type:application/rss+xml");
echo '<?xml version=\"1.0\"?>
<data>
<result status="1">
<url>'.$basepath.'converted.jpg'.'</url>
</result>
</data>';
的錯誤是imagecreatefromstring是返回false值,如果你遇到這樣的問題,請幫助。我不知道圖像是否損壞或者我在這裏做錯了什麼。任何建議或幫助都很棒。謝謝。
你能否包含你的flash代碼? –