search

Home  >  Q&A  >  body text

How to save a good verification code image locally in php?

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_u1582phpcn_u15822792 days ago607

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 13:06:04

    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;//返回图片地址

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 13:06:04

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

    is the local path address

    reply
    0
  • Cancelreply