php保存二进制原始数据为图片的程序代码
得到post过来的二进制原始数据,选择一个生成路径及图片的名字,之后写入,思路很显而易见
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
//生成图片 $imgDir = 'uploadImg/'; $filename="nissangcj".$mobile.".jpg";///要生成的图片名字
$xmlstr = $GLOBALS[HTTP_RAW_POST_DATA]; if(empty($xmlstr)) { $xmlstr = file_get_contents('php://input'); }
$jpg = $xmlstr;//得到post过来的二进制原始数据 if(empty($jpg)) { echo 'nostream'; exit(); }
$file = fopen("./".$imgDir.$filename,"w");//打开文件准备写入 fwrite($file,$jpg);//写入 fclose($file);//关闭
$filePath = './'.$imgDir.$filename;
//图片是否存在 if(!file_exists($filePath)) { echo 'createFail'; exit(); } |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor
