I am in need of being able to upload files larger than 2MB, and am having trouble getting it to work. I am using php 4.3.11 and MySQL 4.1.8 on a Windows server under IIS.

I am aware of the three different ways of changing this value. I can do it in php.ini, but this is a shared server and it is not a good solution to change this globally. I can do it with .htaccess, but that's an apache only solution (AFAIK) and will not help me while running IIS. That leaves using ini_set() in a script, which is my preferred method anyway since it can be changed dynamically and in proper scope.

However, it's not working for me. Here's a function I created to present a form for choosing the file to upload:

function BlobEdit($aid,$blob=null)
{
	ini_set('upload_max_filesize', '60M');     
ini_set('max_execution_time', '999'); ini_set('memory_limit', '128M'); ini_set('post_max_size', '60M'); $trimcolor = GetConfigVar('TrimColor'); $uploadTypes = GetConfigVar('UploadType'); $page = ""; $page .= "<table width=\"95%\" border=\"1\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\" style=\"border-collapse: collapse\">"; $page .= "<tr><td width=\"34%\" align=\"center\" bgcolor=".$trimcolor." nowrap><em><font color=\"#FFFFFF\" size=\"2\">File</font></em></td><td><form name=\"uploads\" action=\"index.php?func=detailedit&aid=$aid\" method=\"post\" enctype=\"multipart/form-data\"><input type=\"File\" name=\"blob\" size=\"60\"></td></tr>"; $page .= "<tr><td width=\"34%\" align=\"center\" bgcolor=".$trimcolor." nowrap><em><font color=\"#FFFFFF\" size=\"2\">Title</font></em></td><td><input type\"text\" name=\"blob_title\" id=\"blob_title\" size=\"70\"></td></tr>"; $page .= "<tr><td width=\"34%\" align=\"center\" bgcolor=".$trimcolor." nowrap><em><font color=\"#FFFFFF\" size=\"2\">File Type</font></em></td><td>".SelectList($uploadTypes,'uploadtype',null,"Select One",'ConfigVal','ConfigVal',null,null,'onChange="passText(this.form.uploadtype.options[this.form.uploadtype.selectedIndex].value);"')."<input type=\"text\" name=\"blob_req\" id=\"blob_req\" size=\"70\" ></td></tr>"; $page .= "<input name=\"abstractid\" type=\"hidden\" id=\"abstractid\" value=\"".$aid."\">"; $page .= "<tr><td width=\"34%\" align=\"center\" bgcolor=".$trimcolor." nowrap><em><font color=\"#FFFFFF\" size=\"2\">Description of File<br>(what does it show)</font></em></td><td align=\"center\" colspan=\"2\"><textarea name=\"blob_desc\" type=\"text\" rows=\"10\" cols=\"55\" id=\"blob_desc\"></textarea></td></tr>"; $page .= "</table>"; $page .= "<p align=\"center\">"; $page .= "<span class=\"instructions\">Click on the button below to Save the file.</span><br><br>"; $page .= "<input type=\"submit\" name=\"cmdSubmit\" value=\"Add and Save File\"><br><br>"; $page .= "</form>"; $page .= ini_get('upload_max_filesize')."<br>"; $page .= ini_get('max_execution_time')."<br>"; $page .= ini_get('memory_limit')."<br>"; $page .= ini_get('post_max_size')."<br>"; return $page; }

The ini_set() functions should set the values, and the ini_get() functions are there to confirm what's been set. I set the values high enough to be noticable. When the form is displayed, the values displayed are:

upload_max_filesize: 2M
max_execution_time: 999
memory_limit: (none shown)
post_max_size: 8M

Those values are default values from php.ini except for max_execution_time. When I try the script, no file is uploaded unless the file size is less than 2MB.

Looking closely at the php docs, it lists upload_max_size as PHP_INI_PERDIR, which I think means it can only be set in the ini and .htaccess files. Interestingly, it also notes that "PHP_INI_ALL in PHP <= 4.2.3". So we've lost an option since v4.2.3(?).

Anybody know more about this? Am I out of luck (other than php.ini) for setting this variable? Has anybody gotten this to work on Windows/IIS specifically, and if so can you show me an example?

Thanks

Rob

    You wont be able to change it unless you have access to httpd.conf or php.ini. Only option is to have the host change it for you.

      Thanks for what I (unfortunately) expected to hear 🙁

        Write a Reply...