In my website, the user can upload a profile image. The website structure is as follows:
C:\xampp\htdocs
C:\xampp\upload\user1
For security reason, the upload file has been moved into folder C:\xampp\upload\user1\.
The question is how I can serve this image later to the user. In other words, after uploading the image, the user should be able to see the upload image on the web page. What should I do?
Here is what I can figure out
- Introduce a new folder
C:\xampp\htdocs\picture\randomimagenamewhich is used to temporarily save the user's picture. - Use the link to
C:\xampp\htdocs\picture\randomimagenameand serve it to the user.
Now the problem is when should I delete this image?
- when the user logouts out. yes, I know how to do this.
- when the user closes the browser. how do I know this?
- any other cases.