Fork me on GitHub
Subscribe 2

Ticket #540 (fixed bug)

File uploads fail on Windows when magic_quotes_gpc is enabled

  • Created: 2011-11-18 03:45:43
  • Reported by: quy
  • Assigned to: quy
  • Milestone: 1.4.8
  • Component: code
  • Priority: normal

On Windows, when magic_quotes_gpc is enabled, valid backslashes are stripped from tmp_name path in $_FILES causing file uploads to fail.


daris 2011-11-30 19:03:00

  • Uploaded patch files.diff. (view)

Commit or wait for a better solution? tongue

quy 2011-12-01 04:41:46

The solution will not work with multiple file uploads when declared like this: req_file[]

quy 2011-12-01 04:49:13

Here is my suggestion:

	if (is_array($_FILES))
		// Don't strip valid slashes from tmp_name path on Windows
		foreach ($_FILES AS $key => $value)
			$_FILES[$key]['tmp_name'] = str_replace('\\', '\\\\', $value['tmp_name']);
		$_FILES = stripslashes_array($_FILES);


daris 2011-12-01 10:47:21

Your solution works as it should smile

quy 2011-12-01 17:05:31

Commit 8d723e7 to fluxbb fluxbb-1.4

#540: Fixed file uploads failing on Windows when magic_quotes_gpc is enabled

quy 2011-12-01 17:07:13

  • Owner set to quy.
  • Status changed from open to fixed.