Home Backend Development PHP Tutorial php环境无法上传文件的解决方法_PHP

php环境无法上传文件的解决方法_PHP

Jun 01, 2016 am 11:55 AM
php environment

一、 检查网站目录的权限。

上传目录是否有写入权限。

二、 php.ini配置文件
php.ini中影响上传的有以下几处:

file_uploads 是否开启 on 必须开启

是否允许HTTP文件上传

post_max_size = 8M

PHP接受的POST数据最大长度。此设定也影响到文件上传。
要上传大文件,该值必须大于"upload_max_filesize"
如果配置脚本中激活了内存限制,"memory_limit"也会影响文件上传。
一般说来,"memory_limit"应该比"post_max_size"要大。

upload_max_filesize = 2M

允许上传的文件的最大尺寸

upload_tmp_dir = C:\windows\temp
文件上传时存放文件的临时目录。必须是PHP进程用户可写的目录。如果未指定则PHP使用系统默认值

default_socket_timeout = 60
socket超时,单位是秒

max_execution_time = 30
每个脚本最大允许执行时间, 按秒计。默认为30秒。
这个参数有助于阻止劣质脚本无休止的占用服务器资源。
注: "max_execution_time"仅影响脚本本身的运行时间。
任何其它花费在脚本运行之外的时间,如用system()/sleep()函数的使用、数据库查询、文件上传等都不包括在内。
在安全模式下,你不能用ini_set()在运行时改变这个设置

max_input_time = 60
每个脚本接收输入数据的最大允许时间(POST, GET, upload), 按秒计

memory_limit = 128M
设定一个脚本所能够申请到的最大内存字节数。
这有助于防止劣质脚本消耗完服务器上的所有内存。
要使用此指令必须在编译的时候激活。
因此 configure 一行中应该包括:--enable-memory-limit
如果不需要任何内存上的限制,必须将其设为 -1
自php4.3.2 起,当设置了memory_limit后,memory_get_usage()函数将变为可用

三、upload_tmp_dir目录权限
如果php配置没问题,那问题有可能出在upload_tmp_dir设定的目录权限问题。加入IIS_WPG除完全控制外的权限,users的读写权限,NETWORK SERVER除完全控制外的权限。

四、如果起用了ZEND,看Temp文件夹中是否有ZendOptimizer.MemoryBase@SYSTEM和ZendOptimizer.MemoryBase@NETWORKSERVICE,如果没有,就建立它。

五、如果以上都不行,那问题很有可能出在这里了,检查windows目录是否禁用guests来宾组,要给windows目录users组 读取和执行权限。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

How does PHP type hinting work, including scalar types, return types, union types, and nullable types? How does PHP type hinting work, including scalar types, return types, union types, and nullable types? Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

See all articles