Php File Upload

Embed Size (px)

Citation preview

PHP File uploading

post_max_size, upload_max_filesize & memory_limit

Write an HTML

PHP Documentationhttp://www.php.net/manual/features.file-upload.php

enctype=multipart/form-data means Content-type of HTTP Request is multipart/form-data

FileFilePHP Directives

header

Part 1Part 2Part 3decodedecode

HTTP RequestHTTP Request HeaderContent-type: multipart/form-dataHTTP Request Body

post_max_size

upload_max_filesize

upload_max_filesize

Decoding needs tiny working buffer. The buffer is allocated within memory_limit.PHP 5.2

PHP Directives

At least, you must satisfy

memory_limitThere are almost no relations with file uploading.

If you want to read whole uploaded files in PHP, you'll consume huge memory. But it is another thing from file uploading.

post_max_size > upload_max_filesize * (how many files) * 1.3

PHP 5.2

Appendix. Specifications

XHTMLhttp://www.w3.org/TR/xhtml1/

See HTML4 spec

HTML 4http://www.w3.org/TR/html4/

17.13.4 Form content types

See RFC 2388

RFC 2388http://www.ietf.org/rfc/rfc2388.txt