简体   繁体   English

PHP文件上传-php.ini

[英]PHP File Uploads - php.ini

I've a site that is uploading images and I just wanted to ask how to set a couple of php.ini settings: 我有一个上传图像的网站,我只想问一下如何设置几个php.ini设置:

max_file_uploads (The maximum mumber of files that can be uploaded in 1 go).

Does the above setting mean the total number of files that can be uploaded by a users session and the amount at one time. 以上设置是否表示一次用户会话可以上传的文件总数以及一次的数量。 eg: users can upload 8 images total. 例如:用户总共可以上传8张图像。 If I set this to 1 does it mean 1 images at a time or total of 1? 如果将其设置为1,是一次表示1张图像还是1张图像? Would setting it to 8 make sense or should I set it to a higher number of users can upload and then change their mind. 将其设置为8是有意义的,还是应该将其设置为更多的用户可以上传然后改变主意。

upload_tmp_dir      /custom/location    Change the location of where files are initally uploaded to

Should this be set outside the document root for php to upload too? 是否也应该在文档根目录之外设置php来上传? What is a typical location? 什么是典型位置? /var/php_images? / var / php_images? I'm using open_basedir so should this path be included in here to? 我使用的是open_basedir,因此此路径应包含在此处吗?

The max_file_uploads directive specifies the maximum number of files that can be uploaded per request. max_file_uploads指令指定每个请求可以上传的最大文件数。 PHP doesn't care about your sessions or anything. PHP不在乎您的会话或其他任何内容。 So, if you have a form with 3 upload inputs, and you only allow 1 on the server, and your users send more than 1, then they will have exceeded the max. 因此,如果您有一个包含3个上载输入的表单,并且您在服务器上只允许1个,而您的用户发送了1个以上,那么他们将超过最大数量。

upload_tmp_dir should always be outside of your doc root. upload_tmp_dir应该始终在文档根目录之外。 In addition, when you move files out of this temporary directory, keep it outside of the doc root, for security. 另外,出于安全考虑,将文件移出该临时目录时,请将其保留在doc根目录之外。 Don't name files the names users specify. 不要为用户指定的文件命名。 Don't use file extensions. 不要使用文件扩展名。 Keep the original names, types, and what not in a database. 保留原始名称,类型以及数据库中未包含的内容。 Use a PHP script to retrieve them on the web side of things, if needed. 如果需要,使用PHP脚本在事物的Web端检索它们。

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

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