如何在用户离开页面时删除文件? [英] How to delete a file whenever user leaves page?

查看:73
本文介绍了如何在用户离开页面时删除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单设置为一个php文件(verify.php)。
在表单中,我制作了一个非常漂亮的图片上传部分。
提交表单后,将打开verify.php以验证用户填写的表单。



表单值全部放置在另一个表单中verify.php页面。
只有图像上传到服务器上的文件夹,这是我的问题。
如果用户感到遗憾(不验证)放入广告,或者用户再次更换广告,我希望图片被删除。



我怎么做到这一点?



一种方法是在页面'unLoads'(用户点击返回按钮)时删除文件名。但是,如果用户关闭了verify.php页面上的浏览器,那不会解决这个问题,因为那不算作'卸载'吗?

解决方案?



如果您需要更多的输入信息,请告诉我,我会更新此帖子!



谢谢

解决方案

不幸的是,这是一件非常棘手的事情,更简单的解决方案是检查哪些文件是旧的,并在下次访问时删除它们这一页。这可以完全通过PHP完成,并且非常可靠。


I have a form with action set to a php-file (verify.php). In the form, I have made a pretty nice picture upload section. After submitting the form, the verify.php is opened to verify the form filled in by the user.

The form values are all placed inside another form on the verify.php page. Only the image is uploaded to a folder on the server, and this is my problem. I want the image to be deleted if the user regrets (doesn't verify) putting in an ad, or if the user goes back to change the ad again.

How would I do this?

One way could be to delete the filename whenever page 'unLoads' (user hits back button). But that wont solve the problem if the user closes the browser on the verify.php page, because that doesnt count as an 'unload' does it?

Solutions?

If you need more input, tell me and I will update this post!

Thanks

解决方案

Unfortunately this is a pretty tricky thing to do, the easier solution would be to check to see which files are old and delete them the next time someone accesses the page. This could be done completely through PHP and would be very reliable.

这篇关于如何在用户离开页面时删除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆