简体   繁体   English

如何隐藏一个用户从另一个用户在php中上传的图像?

[英]how to hide an image uploaded by a user from another user in php?

I am working on a website which sells spectacles and website provides the try on feature to users so that user can try the spec on his image. 我正在一家销售眼镜网站上工作,该网站向用户提供了试戴功能 ,以便用户可以在其图像上尝试该规格。

Now when a user upload an image he try specs on his photo but if any other user upload his photo he also finds the uploaded image by the other user and if the second user upload his photo then the image which was uploaded by the first user deleted. 现在,当一个用户上传图像时,他尝试对自己的照片进行规范,但是如果其他用户上传了他的照片,他还会找到其他用户上传的图像,如果第二位用户上传了他的照片,则第一个用户上传的图像将被删除。

How to solve this problem? 如何解决这个问题呢?

Generate a unique random name (using eg uniqid() ) for each uploaded file and tie it to the user session id or shop account. 为每个上传的文件生成一个唯一的随机名称(例如使用uniqid() ),并将其绑定到用户会话ID或商店帐户。 This way, users always see their picture (you can show him his picture next time he visits - if he has an account). 这样,用户总是可以看到他们的照片(如果他有帐户,则可以在他下次访问时向他显示他的照片)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM