Overwrite php.ini settings on IIS - php

I tried to make an PHP upload form on a windows server, but the upload didn't work because there's no temporary directory. I checked which value is set for the upload_temp_dir and phpinfo() says "no value".
Is it possible to overwrite the php.ini settings for upload_tmp_dir on a IIS? I have no access to the php.ini file. I looked for a possibility to change it with help of a web.config file, but with no result.

have a look at the function
init_set()
http://php.net/manual/en/function.ini-set.php

You can change PHP config by creating a ".user.ini" file. For example, the following will enable the short open tag for your site:
short_open_tag = On
Upload the file to the root directory of your site.
If the PHP version is 5.3 or 5.6 the file name is: user.ini
For any other PHP version the file name is: .user.ini

Related

How to override the php.ini file settings in laragon?

When i upgrade my php version from 7.1 to 7.2 there is new folder include in
c:\laragon\bin\php
which is right. But when i edit the php.ini file and enable openssl and other extension, save it and restart than it will override by the previous php.ini. It happens to two three times. I think there is a global php.ini file. If it has then how can we override this php.ini files with other versions php.ini?
If anyone knows please describe it or give me suggestion. Thanks
I think you just installed php incorrectly in laragon, check the folder "C:\laragon\bin\php\php-7.3.21\ext" and if this folder is empty then that would mean there is no extension, even after activation it will not change the "php.ini" file. I had the same problem.
Looks like the response
I think there is a global php.ini file
..is wrong. Please change anything (extension) in the specific php directory that you will use. This is the php directory of laragon on my local, if I will use php version 8, then I change the php.ini file in "php-8.0.8-nts-Win32-vs16-x64".
Like this:

When php.ini or .user.ini file is loaded on the server?

I am new to the world of web and want to know that when server default php.ini file, custom php.ini(that we created manually and added into per directory) file, .user.ini file is loaded/read by the server ?
According to my concept these files are loaded/read on each request or loaded/read on each process at the cgi.
Can anyone tell in easy words ?
Referring to the documentation, the default php.ini is loaded, when php is started. You can place your custom user.ini in the same location. Php is looking in default directories for all *.ini-files for including. You have to restart php whenever you apply changes to the configuration.
FYI, manual - the configuration file

How to change default path for php.ini in PHP?

When I see phpinfo(), it shows the path of php.ini file as: \apache2.2.22\bin\php.ini
But I want to load php.ini file from PHP executable folder. I tried to modify it from regedit but PHP is not available in regedit!
I am trying to create the php extension in c++ where I want to create extension for introduction.dll file. I copied this dll file in php/ext folder and set all the parameters in php.ini
But later I found that php.ini file loaded using phpinfo() was from apache!
Any idea?
Referring to http://php.net/manual/en/install.windows.apache2.php you can specify a "PHPIniDir" directive in your apache configuration (at least if you run it as a module).

How to support upload on PHP installed with IIS 7.0?

I install PHP on IIS 7.0 at Windows Server 2008 and Windows 7. I have setup Wordpress and Joomla and config finished.
But I find I can not upload any file with PHP program but okay under ASP.NET.
I had,
Config the every permission with write of Upload folder to IUSR and IIS_USRS
Config the PHP.ini with file_uploads = On
Setup a temp directory and config for every permission with write. upload_tmp_dir = "E:\Webware\PHP.Upload.Tmp"
Reboot IIS
But I still can not upload file via PHP program.
When you run phpinfo() what is the value of your upload_tmp_dir?
I'd wager your upload_tmp_dir variable in the [PHP] configuration section of php.ini file is being overwritten in the [WebPIChanges] configuration section, towards the end of your php.ini file...
Depending on how you installed PHP, there may be two upload_tmp_dir variables in your php.ini file, and if the the second one is set, it will overwrite the first.
Take a look at this site, it may help you: http://www.radinks.com/upload/config.php
Also i suggest you to don't modify upload_temp_dir

php.ini not working in IIS?

I've set magic_quotes_gpc = Off in php.ini,but I see it's still On in phpinfo();
First of all, you must be sure you modified the right php.ini file : there can be many files called php.ini -- and only one is "the right one".
You can see which php.ini file is used in the output of phpinfo() : there should be an entry called Configuration File (php.ini) Path that indicates the directory in which php.ini is looked for, and an entry called Loaded Configuration File that indicates the full path+name of the php.ini file that's used.
Then : don't forget to restart the webserver, so the modifications to php.ini are taken into account (Not sure that's necessary with IIS, but as it's required with Apache, I suppose it cannot hurt with IIS)
If that doesn't change a thing : what if you try to modify another directive : is the modification taken into account ?
As an alternative, you can disable it from your script too:
// disable magic_quotes_runtime
if (get_magic_quotes_runtime())
{
#set_magic_quotes_runtime(0);
}
You can check the php.ini file that was loaded via the php_ini_loaded_file function. Restart your web server.
On my installation the c:\php\php.ini file was named php ini. So phpmyinfo() was not loading it, despite the PATH environment variable including C:\php\. (Check this in a DOS prompt with SET PATH).
So rename it to php.ini.
It was difficult to spot in Windows Explorer.

Categories