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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools