File Uploading
Page: 1, 2
@senixon
Does your solution probably work on a *nix server?
@mvdbrand
Did you try it? Result?
Does your solution probably work on a *nix server?
@mvdbrand
Did you try it? Result?
@ senixon,
Thanks for your solution. Now file system is running on my server well!!! :)
Thanks for your solution. Now file system is running on my server well!!! :)
Above fix did not work for me. I have openbase_dir in effect. On Apache 2 with PHP 5 running Fedora Core 4, (Linux) and applied above fix. Still getting same error. All permission are correct.
Senixon, this function doesn`t work on PHP5.1.6, Linux 2.6.18-1.2798.fc6, Apache/2.2.3 (Fedora). Nothing interesting happens, the same error occurs.
alexkingorg
on May 30. 2008. 6:53 am
The function above didn't work for me (CentOS), but this did. It's PHP5 only due to the strrpos usage - that could likely be replaced with strpos with no ill effects for PHP4 users.
function force_mkdir($path, $chmod = null) {
if (is_dir($path)) {
return true;
} // if
$real_path = str_replace('\\', '/', $path);
$parts = explode('/', $real_path);
$forced_path = '';
$path_start = strrpos($path, 'upload');
foreach ($parts as $part) {
if (empty($part)) {
continue;
}
// Skip first on windows
if ($forced_path == '') {
$start = substr(__FILE__, 0, 1) == '/' ? '/' : '';
$forced_path = $start . $part;
} else {
$forced_path .= '/' . $part;
} // if
if (strlen($forced_path) > $path_start && !is_dir($forced_path)) {
if (!is_null($chmod)) {
if (!mkdir($forced_path)) {
die('test'.$forced_path);
return false;
} // if
} else {
if (!mkdir($forced_path, $chmod)) {
return false;
} // if
} // if
} // if
} // foreach
return true;
} // force_mkdir



