note 25989 added to function.is-uploaded-file

From: Date: Mon, 14 Oct 2002 17:44:59 +0000
Subject: note 25989 added to function.is-uploaded-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-38060@lists.php.net to get a copy of this message
to get the example to work on windows, youll have to add a line, that replaces backslashes with slashes. eg.: $filename = str_replace ("\\", "/", $filename); also, as someone mentioned, globalizing $HTTP_POST_FILES is a good idea ... <pre> /* Userland test for uploaded file. */ function is_uploaded_file($filename) { global $HTTP_POST_FILES; if (!$tmp_file = get_cfg_var("upload_tmp_dir")) { $tmp_file = dirname(tempnam("", "")); } $tmp_file .= "/" . basename($filename); /* User might have trailing slash in php.ini... */ // fix for win platform $filename = str_replace ("\\", "/", $filename); return (ereg_replace("/+", "/", $tmp_file) == $filename); } </pre> -- http://www.php.net/manual/en/function.is-uploaded-file.php http://master.php.net/manage/user-notes.php?action=edit+25989 http://master.php.net/manage/user-notes.php?action=delete+25989 http://master.php.net/manage/user-notes.php?action=reject+25989

« previous php.notes (#38060) next »