PHP - Store Images in SESSION data?

后端 未结 7 1008
一向
一向 2020-12-30 01:21

Can you store an image in a PHP SESSION ?

I have a multi-step registration process using PHP on my site. On one of the steps, the users can upload their company log

7条回答
  •  悲哀的现实
    2020-12-30 01:53

    If you have to keep the data, I would suggest keeping it as base64_encoded string. You can directly send base64_encode image data to the browser.

    If I'd be in similar situation i would have rather saved the image and kept the information about the image in session/db. If for some reason the registration fails, i would unlink the file later. and occasionally run cron jobs to locate missing links with the images.

    But i will really suggest you to stick to the second option and avoid the hassle altogether.

提交回复
热议问题