开发者

When uploading, where do I set the php.ini parameters?

In the script where the upload form is, or the script that processes the action?

Example parameters:

memory_limit

EDIT: Ok, let me clarify. First, I didn't know the 2nd, 3rd and 4th parameter could not be changed using ini_set(). Now, I want to know where exactly I should call the ini_set() function. In the form script or the action handling script?

Here's an example to illustrate what I'm looking for:

form.php

<form action="post.php">
  <input type="text" name="search" />
  <inpu开发者_如何转开发t type="submit" />
</form>

post.php

<?php //handle search ?>

So under which file must my ini_set() function should go?


You have to set these parameters initially from php.ini. You cannot change this from a PHP script except memory_limit, for the remaining Just search for those keys you mentioned in php.ini and change their values.

For memory_limit you can use following snippet at your processing page handling the uploads like in your case at post.php

ini_set("memory_limit","16M");

OR

You can create a .htaccess file at the root directory, if your server support mod_rewrite modules you can change them like this

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200


You set them in the php.ini file, on your server. The location of this file depends on your server and its setup. On Linux it can usually be found under the /etc/php*** directory. On Windows, in the PHP installation directory.


  • you can use ini_set to set those parameters dynamicly
  • you can set them in your virtualhost/Location section of apache
  • you can set them in some htaccess using php_value directive
  • you can set them in your php.ini

So you have a lot of possibilities depending the one you are using the parameters might be enabled to the whole server, a script in particular, a website in particular, an url in particular.


Create a .htaccess file in the document root and add the following lines

php_value memory_limit 100M
php_value post_max_size 50M
php_value upload_max_filesize 50M

You can set the size you required.

max_file_uploads cannot be changed. http://bugs.php.net/bug.php?id=50684&edit=1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜