How to save a good verification code image locally in php?
phpcn_u1582
phpcn_u1582 2017-05-16 13:04:04
0
2
574

Use PHP to draw login verification pictures. Since the pictures are taken locally, I don’t want to return the picture in the form of a link. I want to name the drawn verification code picture, then save it to the specified path, and then return a local Give the url address to the front desk, and the front end directly inserts the address in <img src="url"/>. How to achieve this? Thank you~

< /p>

< br>Up to this point, I just output a png image to the browser. How do I name the image and save it locally?

Also, is this approach correct?


Img’s src can be written to death

If the data obtained by ajax is placed in the src of img, an error will be reported

phpcn_u1582
phpcn_u1582

reply all(2)
Peter_Zhu

Don’t generate pictures anymore. Save it every time you refresh. Think about your hard drive space. If you must do this
modify the eighth line

$imgpath = time().rand(10000,99999).'.png';//生成图片的位置。具体路径需要指定
imagepng($imge,$imgpath);//报错图片
echo $imgpath;//返回图片地址
淡淡烟草味

$pic = "C:pic.png";
imagepng($im,$pic);

is the local path address

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template