文件上传:应该是什么文件来保存的名字吗? [英] File uploading : What should be the name of the file to save to?

查看:341
本文介绍了文件上传:应该是什么文件来保存的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将文件上传控件添加到我的ASP.NET 2.0的网页,使用户可以上传文件。文件将被存储在服务器中的文件夹中具有名称作为用户的。我想知道什么是保存到服务器时命名文件的最佳选择。需要考虑安全性,性能,灵活性来处理文件等如果我错过了什么,请指导我。

I am going to add file upload control to my ASP.NET 2.0 web page so that users can upload files. Files will be stored in the server in the folder with the name as of the user. I want to know what is the best option to name the files when saving to server. Needs to consider Security, Performance, Flexibility to handle files etc. If I miss anything, please guide me

选项我正在考虑现在:


  1. 具有相同的名称作为上传输入文件名

  2. 添加用户ID +随机数+文件名输入文件名

  3. 在秒的时间创建随机数+当前时间并保存这个数字文件。将有一个表来映射这个号码与用户上传

任何其他人的事情吗?什么是最好的方法是什么?

Any thing else? What is the best way?

在此先感谢

推荐答案

永远不要为文件名的用户输入。不要使用用户名。用户的用户ID,而不是(我假设你的用户有一个唯一的ID)。

NEVER EVER use user input for filenames. Don't use the username. User the user id instead (I assume your users have an unique id).

切勿使用原来的文件名。使用您的解决方案,3号,加上用户ID,而不是用户名。

NEVER use the original filename. Use your solution number 3, plus the user id instead of the username.

有关您的信息,PHP有一个漏洞几年前:人们可以用伪造的文件上传一个HTTP POST请求,并包含../../anything.php的文件名,并且PHP _FILES数组,应包含消毒值,没有发现这类文件名,所以人们可以在文件系统中的任意位置写入文件。

For your information, PHP had a vulnerability a few years ago: one could forge a HTTP POST request with a file upload, and with a file name like "../../anything.php", and the php _FILES array, supposed to contain sanitized values, didn't detect these kind of file names, so one could write files anywhere in the filesystem.

这篇关于文件上传:应该是什么文件来保存的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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