summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-09-08 22:31:21 +0000
committerZeev Suraski <zeev@php.net>2000-09-08 22:31:21 +0000
commit3edf46ff735f1f9d51979c31097335d819e71f7a (patch)
treea3738785b09a8cdc055c4f9c802c1a4abf304a06 /ext/standard/basic_functions.c
parentfa6bb5977392a4c33dc60a680276e54090bb4e00 (diff)
downloadphp-git-3edf46ff735f1f9d51979c31097335d819e71f7a.tar.gz
Implement move_uploaded_file() (untested)
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r--ext/standard/basic_functions.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 973fc3d3e4..7add16113f 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2228,6 +2228,41 @@ PHP_FUNCTION(is_uploaded_file)
}
}
+
+PHP_FUNCTION(move_uploaded_file)
+{
+ zval **path, **new_path;
+ SLS_FETCH();
+
+ if (!SG(rfc1867_uploaded_files)) {
+ RETURN_FALSE;
+ }
+
+ if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &path, &new_path)!=SUCCESS) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ convert_to_string_ex(path);
+ convert_to_string_ex(new_path);
+
+ if (!zend_hash_exists(SG(rfc1867_uploaded_files), Z_STRVAL_PP(path), Z_STRLEN_PP(path)+1)) {
+ RETURN_FALSE;
+ }
+
+ if (rename(Z_STRVAL_PP(path), Z_STRVAL_PP(new_path))==0) {
+ RETURN_TRUE;
+ }
+
+ if (php_copy_file(Z_STRVAL_PP(path), Z_STRVAL_PP(new_path))==SUCCESS) {
+ unlink(Z_STRVAL_PP(path));
+ RETURN_TRUE;
+ }
+
+ php_error(E_WARNING, "Unable to move '%s' to '%s'", Z_STRVAL_PP(path), Z_STRVAL_PP(new_path));
+
+ RETURN_FALSE;
+}
+
+
/*
* Local variables:
* tab-width: 4