• 17 minutes to read

All file systems supported by Windows use the concept of files and directories to access data stored on a disk or device. Windows developers working with the Windows APIs for file and device I/O should understand the various rules, conventions, and limitations of names for files and directories.

Data can be accessed from disks, devices, and network shares using file I/O APIs. Files and directories, along with namespaces, are part of the concept of a path, which is a string representation of where to get the data regardless if it’s from a disk or a device or a network connection for a specific operation.

Some file systems, such as NTFS, support linked files and directories, which also follow file naming conventions and rules just as a regular file or directory would. For additional information, see Hard Links and Junctions and Reparse Points and File Operations.

For additional information, see the following subsections:

  • File and Directory Names
    • Naming Conventions
    • Short vs. Long Names
  • Paths
    • Fully Qualified vs. Relative Paths
    • Maximum Path Length Limitation
  • Namespaces
    • Win32 File Namespaces
    • Win32 Device Namespaces
    • NT Namespaces
  • Related topics

File and Directory Names

All file systems follow the same general naming conventions for an individual file: a base file name and an optional extension, separated by a period. However, each file system, such as NTFS, CDFS, exFAT, UDFS, FAT, and FAT32, can have specific and differing rules about the formation of the individual components in the path to a directory or file. Note that a directory is simply a file with a special attribute designating it as a directory, but otherwise must follow all the same naming rules as a regular file.

cause the term directory simply refers to a special type of file as far as the file system is concerned, some reference material will use the general term file to encompass both concepts of directories and data files as such. Because of this, unless otherwise specified, any naming or usage rules or examples for a file should also apply to a directory. The term path refers to one or more directories, backslashes, and possibly a volume name. For more information, see the Paths section.

Character count limitations can also be different and can vary depending on the file system and path name prefix format used. This is further complicated by support for backward compatibility mechanisms. For example, the older MS-DOS FAT file system supports a maximum of 8 characters for the base file name and 3 characters for the extension, for a total of 12 characters including the dot separator. This is commonly known as an 8.3 file name. The Windows FAT and NTFS file systems are not limited to 8.3 file names, because they have long file name support, but they still support the 8.3 version of long file names.

Naming Conventions

The following fundamental rules enable applications to create and process valid names for files and directories, regardless of the file system:

  • Use a period to separate the base file name from the extension in the name of a directory or file.

  • Use a backslash () to separate the components of a path. The backslash divides the file name from the path to it, and one directory name from another directory name in a path. You cannot use a backslash in the name for the actual file or directory because it is a reserved character that separates the names into components.

  • Use a backslash as required as part of volume names, for example, the "C:" in "C:pathfile" or the "\servershare" in "\serversharepathfile" for Universal Naming Convention (UNC) names. For more information about UNC names, see the Maximum Path Length Limitation section.

  • Do not assume case sensitivity. For example, consider the names OSCAR, Oscar, and oscar to be the same, even though some file systems (such as a POSIX-compliant file system) may consider them as different. Note that NTFS supports POSIX semantics for case sensitivity but this is not the default behavior. For more information, see CreateFile.

  • Volume designators (drive letters) are similarly case-insensitive. For example, "D:" and "d:" refer to the same volume.

  • Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

    • The following reserved characters:

      • < (less than)
      • (greater than)

      • : (colon)
      • " (double quote)
      • / (forward slash)
      • (backslash)
      • | (vertical bar or pipe)
      • ? (question mark)
      • * (asterisk)

    • Integer value zero, sometimes referred to as the ASCII NUL character.

    • Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.

    • Any other character that the target file system does not allow.

  • Use a period as a directory component in a path to represent the current directory, for example ".temp.txt". For more information, see Paths.

  • Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory, for example "..temp.txt". For more information, see Paths.

  • Do not use the following reserved names for the name of a file:

    CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.

  • Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, ".temp".

Short vs. Long Names

A long file name is considered to be any file name that exceeds the short MS-DOS (also called 8.3) style naming convention. When you create a long file name, Windows may also create a short 8.3 form of the name, called the 8.3 alias or short name, and store it on disk also. This 8.3 aliasing can be disabled for performance reasons either systemwide or for a specified volume, depending on the particular file system.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: 8.3 aliasing cannot be disabled for specified volumes until Windows 7 and Windows Server 2008 R2.

On many file systems, a file name will contain a tilde (~) within each component of the name that is too long to comply with 8.3 naming rules.


To request 8.3 file names, long file names, or the full path of a file from the system, consider the following options:

  • To get the 8.3 form of a long file name, use the GetShortPathName function.
  • To get the long file name version of a short name, use the GetLongPathName function.
  • To get the full path to a file, use the GetFullPathName function.

On newer file systems, such as NTFS, exFAT, UDFS, and FAT32, Windows stores the long file names on disk in Unicode, which means that the original long file name is always preserved. This is true even if a long file name contains extended characters, regardless of the code page that is active during a disk read or write operation.

Files using long file names can be copied between NTFS file system partitions and Windows FAT file system partitions without losing any file name information. This may not be true for the older MS-DOS FAT and some types of CDFS (CD-ROM) file systems, depending on the actual file name. In this case, the short file name is substituted if possible.


The path to a specified file consists of one or more components, separated by a special character (a backslash), with each component usually being a directory name or file name, but with some notable exceptions discussed below. It is often critical to the system’s interpretation of a path what the beginning, or prefix, of the path looks like. This prefix determines the namespace the path is using, and additionally what special characters are used in which position within the path, including the last character.

If a component of a path is a file name, it must be the last component.

Each component of a path will also be constrained by the maximum length specified for a particular file system. In general, these rules fall into two categories: short and long. Note that directory names are stored by the file system as a special type of file, but naming rules for files also apply to directory names. To summarize, a path is simply the string representation of the hierarchy between all of the directories that exist for a particular file or directory name.

Fully Qualified vs. Relative Paths

For Windows API functions that manipulate files, file names can often be relative to the current directory, while some APIs require a fully qualified path. A file name is relative to the current directory if it does not begin with one of the following:

  • A UNC name of any format, which always start with two backslash characters ("\"). For more information, see the next section.
  • A disk designator with a backslash, for example "C:" or "d:".
  • A single backslash, for example, "directory" or "file.txt". This is also referred to as an absolute path.

If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter. Note that the current directory may or may not be the root directory depending on what it was set to during the most recent "change directory" operation on that disk. Examples of this format are as follows:

  • "C:tmp.txt" refers to a file named "tmp.txt" in the current directory on drive C.
  • "C:tempdirtmp.txt" refers to a file in a subdirectory to the current directory on drive C.

A path is also said to be relative if it contains "double-dots"; that is, two periods together in one component of the path. This special specifier is used to denote the directory above the current directory, otherwise known as the "parent directory". Examples of this format are as follows:

  • "..tmp.txt" specifies a file named tmp.txt located in the parent of the current directory.
  • "….tmp.txt" specifies a file that is two directories above the current directory.
  • "..tempdirtmp.txt" specifies a file named tmp.txt located in a directory named tempdir that is a peer directory to the current directory.

Relative paths can combine both example types, for example "C:..tmp.txt". This is useful because, although the system keeps track of the current drive along with the current directory of that drive, it also keeps track of the current directories in each of the different drive letters (if your system has more than one), regardless of which drive designator is set as the current drive.

Maximum Path Length Limitation

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.

local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)


The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\?" prefix. For example, "\?D:very long path".


The "\?" prefix can also be used with paths constructed according to the universal naming convention (UNC). To specify such a path using UNC, use the "\?UNC" prefix. For example, "\?UNCservershare", where "server" is the name of the computer and "share" is the name of the shared folder. These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory. Because you cannot use the "\?" prefix with a relative path, relative paths are always limited to a total of MAX_PATH characters.

There is no need to perform any Unicode normalization on path and file name strings for use by the Windows file I/O API functions because the file system treats path and file names as an opaque sequence of WCHARs. Any normalization that your application requires should be performed with this in mind, external of any calls to related Windows file I/O API functions.

When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name (that is, the directory name cannot exceed MAX_PATH minus 12).

The shell and the file system have different requirements. It is possible to create a path with the Windows API that the shell user interface is not able to interpret properly.


A registry key allows you to enable or disable the new long path behavior. To enable long path behavior set the registry key at HKLMSYSTEMCurrentControlSetControlFileSystem LongPathsEnabled (Type: REG_DWORD). The key’s value will be cached by the system (per process) after the first call to an affected Win32 file or directory function (list follows). The registry key will not be reloaded during the lifetime of the process. In order for all apps on the system to recognize the value of the key, a reboot might be required because some processes may have started before the key was set.

The registry key can also be controlled via Group Policy at Computer Configuration > Administrative Templates > System > Filesystem > Enable NTFS long paths.

You can also enable the new long path behavior per app via the manifest:

<application xmlns="urn:schemas-microsoft-com:asm.v3">  <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">  <ws2:longPathAware>true</ws2:longPathAware>  </windowsSettings> </application> 

These are the directory management functions that no longer have MAX_PATH restrictions if you opt-in to long path behavior: CreateDirectoryW, CreateDirectoryExW GetCurrentDirectoryW RemoveDirectoryW SetCurrentDirectoryW.

These are the file management functions that no longer have MAX_PATH restrictions if you opt-in to long path behavior: CopyFileW, CopyFile2, CopyFileExW, CreateFileW, CreateFile2, CreateHardLinkW, CreateSymbolicLinkW, DeleteFileW, FindFirstFileW, FindFirstFileExW, FindNextFileW, GetFileAttributesW, GetFileAttributesExW, SetFileAttributesW, GetFullPathNameW, GetLongPathNameW, MoveFileW, MoveFileExW, MoveFileWithProgressW, ReplaceFileW, SearchPathW, FindFirstFileNameW, FindNextFileNameW, FindFirstStreamW, FindNextStreamW, GetCompressedFileSizeW, GetFinalPathNameByHandleW.


There are two main categories of namespace conventions used in the Windows APIs, commonly referred to as NT namespaces and the Win32 namespaces. The NT namespace was designed to be the lowest level namespace on which other subsystems and namespaces could exist, including the Win32 subsystem and, by extension, the Win32 namespaces. POSIX is another example of a subsystem in Windows that is built on top of the NT namespace. Early versions of Windows also defined several predefined, or reserved, names for certain special devices such as communications (serial and parallel) ports and the default display console as part of what is now called the NT device namespace, and are still supported in current versions of Windows for backward compatibility.

Win32 File Namespaces

The Win32 namespace prefixing and conventions are summarized in this section and the following section, with descriptions of how they are used. Note that these examples are intended for use with the Windows API functions and do not all necessarily work with Windows shell applications such as Windows Explorer. For this reason there is a wider range of possible paths than is usually available from Windows shell applications, and Windows applications that take advantage of this can be developed using these namespace conventions.

For file I/O, the "\?" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs. For more information about the normal maximum path limitation, see the previous section Maximum Path Length Limitation.

Because it turns off automatic expansion of the path string, the "\?" prefix also allows the use of ".." and "." in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path.

Many but not all file I/O APIs support "\?"; you should look at the reference topic for each API to be sure.

Win32 Device Namespaces

The "\." prefix will access the Win32 device namespace instead of the Win32 file namespace. This is how access to physical disks and volumes is accomplished directly, without going through the file system, if the API supports this type of access. You can access many devices other than disks this way (using the CreateFile and DefineDosDevice functions, for example).

For example, if you want to open the system’s serial communications port 1, you can use "COM1" in the call to the CreateFile function. This works because COM1–COM9 are part of the reserved names in the NT namespace, although using the "\." prefix will also work with these device names. By comparison, if you have a 100 port serial expansion board installed and want to open COM56, you cannot open it using "COM56" because there is no predefined NT namespace for COM56. You will need to open it using "\.COM56" because "\." goes directly to the device namespace without attempting to locate a predefined alias.

Another example of using the Win32 device namespace is using the CreateFile function with "\.PhysicalDiskX" (where X is a valid integer value) or "\.CdRomX". This allows you to access those devices directly, bypassing the file system. This works because these device names are created by the system as these devices are enumerated, and some drivers will also create other aliases in the system. For example, the device driver that implements the name "C:" has its own namespace that also happens to be the file system.

APIs that go through the CreateFile function generally work with the "\." prefix because CreateFile is the function used to open both files and devices, depending on the parameters you use.

If you’re working with Windows API functions, you should use the "\." prefix to access devices only and not files.

Most APIs won’t support "\."; only those that are designed to work with the device namespace will recognize it. Always check the reference topic for each API to be sure.

NT Namespaces

There are also APIs that allow the use of the NT namespace convention, but the Windows Object Manager makes that unnecessary in most cases. To illustrate, it is useful to browse the Windows namespaces in the system object browser using the Windows Sysinternals WinObj tool. When you run this tool, what you see is the NT namespace beginning at the root, or "". The subfolder called "Global??" is where the Win32 namespace resides. Named device objects reside in the NT namespace within the "Device" subdirectory. Here you may also find Serial0 and Serial1, the device objects representing the first two COM ports if present on your system. A device object representing a volume would be something like "HarddiskVolume1", although the numeric suffix may vary. The name "DR0" under subdirectory "Harddisk0" is an example of the device object representing a disk, and so on.

To make these device objects accessible by Windows applications, the device drivers create a symbolic link (symlink) in the Win32 namespace, "Global??", to their respective device objects. For example, COM0 and COM1 under the "Global??" subdirectory are simply symlinks to Serial0 and Serial1, "C:" is a symlink to HarddiskVolume1, "Physicaldrive0" is a symlink to DR0, and so on. Without a symlink, a specified device "Xxx" will not be available to any Windows application using Win32 namespace conventions as described previously. However, a handle could be opened to that device using any APIs that support the NT namespace absolute path of the format "DeviceXxx".

With the addition of multi-user support via Terminal Services and virtual machines, it has further become necessary to virtualize the system-wide root device within the Win32 namespace. This was accomplished by adding the symlink named "GLOBALROOT" to the Win32 namespace, which you can see in the "Global??" subdirectory of the WinObj browser tool previously discussed, and can access via the path "\?GLOBALROOT". This prefix ensures that the path following it looks in the true root path of the system object manager and not a session-dependent path.


File Name

Sandvox automatically sets a page’s file name from its title. The file name is the page title with any characters not in the list above removed and with spaces or punctuation replaced by dashes. So for example, if you title a page Is my site great? Sandvox will provide is-my-site-great as the file name.

If the page title consists solely of characters not in the list (for example a title in Japanese), Sandvox sets the file name to be a random-looking, unique string of letters and numbers.

If you change the title of the page, the automatically generated file name will also update itself to match the page title. Once that page has been published, however, the name no longer changes automatically. This allows you to update a title without losing any links to that published page. (You may change the file name after publication, but keep in mind that there may be links to the old page with the old file name; this file will still exist on your host.)

You can also set a page’s file name manually yourself. There are several advantages for this:

  • If your page has a long title, the automatically generated name may truncate the middle of a word.
  • You can create much more attractive and easy to type URLs by choosing a shorter file name.
  • Your host may require a certain page to have a particular file name.
  • You may want to use keywords that people may be searching for, in order to improve likelihood of being found by search engines.

You cannot change the file name of a site’s Home Page. If you could and did, web browsers would not be able to properly locate the Home Page when visiting the site.

File Extensions

Normally, all pages are published with a file extension of html. You might want to change this for:

  • Compatibility with an unusual web server
  • Constructing a special page type like PHP.

A page’s file extension can be changed, like the file name, from the bottom of the Page Details area.


Практически в каждом проекте разработчик сталкивается с необходимостью загрузки файлов на сервер. Фотографии, картинки, документы, архивы и многое другое может быть загружено на сервер посредством web-интерфейса (через браузер).

Загрузка данных на сервер может происходить одним из двух методов: GET или POST. Метод GET подразумевает, что все параметры передаются в строке URL. Например, строка:


определяет запрос GET к странице index.php. При этом скрипту передаются параметры «name» и «page» со значениями «myname» и «10» соответственно. Как видите, запрос состоит из пар «имя=значение», объединённых через «&». Запрос отделяется от адреса страницы знаком вопроса «?».

Но GET не подходит для передачи больших данных. Для этого существует метод POST. Этот метод передаёт данные скрыто от пользователя, а адрес страницы остаётся неизменным. Теоретически, метод POST позволяет передавать огромные блоки данных, но большинство провайдеров устанавливают жесткое ограничение в 5-10 мегабайт.

Для реализации загрузки файла необходимо снабдить пользователя соответствующей формой. Для загрузки файлов предназначен тег input типа file.

  <form action="receiver.php" method="post"  enctype="multipart/form-data">   Выберите файл для загрузки:    <input type="file" name="ufile" /><br />   <input type="submit" name="send" value="Отправить!" />  </form> 

Пользователь выбирает нужный файл, нажимает кнопку «Отправить!», после чего браузер передаёт указанный файл на сервер. По окончании загрузки файла запускается receiver.php, и ему автоматически становятся доступны все переданные в форме данные.

Список загруженных файлов хранится в глобальном массиве $_FILES. Это ассоциативный массив, где каждый элемент содержит описание одного из файлов. Рассмотрим на примере:

 <?php  // инициализируем нужные переменные  $filename = '';  $filepath = '';  $filetype = '';   // проверяем, что файл загружался  if(isset($_FILES['ufile']) &&  $_FILES['ufile']['error'] != 4)  {  // проверяем, что файл загрузился без ошибок 	if($_FILES['ufile']['error'] != 1 &&  $_FILES['ufile']['error'] != 0) 	{ 	 $error = $_FILES['ufile']['error']; 	 $errors []= 'Ошибка: Файл не загружен.'.  ' Код ошибки: ' . $error; 	} 	else  {  // файл загружен на сервер   // проверяем файл на максимальный размер 	 $filesize = $_FILES['ufile']['size']; 	 if($_FILES['ufile']['error'] == 1 ||  $filesize > 3145728) 	 { 	 	$filesize = ($filesize != 0)?  sprintf('(%.2f Мб)' , $filesize / 1024): ''; 	 	die('Ошибка: Размер прикреплённого файла '.  $filesize.' больше допустимого (3 Мб).'); 	 } 	 else 	 { 	 $filename = $_FILES['file']['name']; 	 	$filepath = $_FILES['file']['tmp_name']; 	 	$filetype = $_FILES['file']['type']; 	 	if($this->filetype == null ||  $this->filetype == '') 	 	 $this->filetype = 'unknown/unknown'; 	 } 	}  }   echo 'Успешно загружен файл: ' . $filename;  ?> 

Все загруженные файлы сохраняются сервером во временном каталоге и автоматически удаляются после завершения скрипта. Если вам необходимо сохранить файл на сервере — его надо переместить в один из каталогов сайта. Для этого служит специальная функция move_uploaded_file(). Обчно она используется в паре с функцией is_uploaded_file(), которая позволяет определить, был ли файл загружен через форму. Например:

 <?php  // $filename - имя загруженого файла  if(is_uploaded_file($filename))  move_uploaded_file($filename,  'files/' . basename($filename));  // файл будет перемещён в каталог files/ ?> 

Информация о каждом загруженном файле представляется в скрипте как элемены массива $_FILES. Имя элемента определяется атрибутом name тега формы. В нашем случае атрибут name равен «ufile», значит данные об этом файле будут храниться в элементе $_FILES[‘ufile’].

Каждый элемент $_FILES так же является массивом, содержащим пять элементов с фиксированными именами:

$_FILES[‘ufile’][‘name’] Содержит исходное имя файла, каким оно было на компьютере пользователя.
$_FILES[‘ufile’][‘type’] Содержит MIME-тип файла. Например, для jpeg-изображения будет содержать «image/jpeg».
$_FILES[‘ufile’][‘size’] Содержит истинный размер переданного файла в байтах.
$_FILES[‘ufile’][‘tmp_name’] Содержит полный путь с загруженному на сервер файлу. Если вам не нужно хранить загруженный файл на сервере — можно пользоваться этим параметром для обращения к файлу.
$_FILES[‘ufile’][‘error’] Содержит код ошибки, если таковая имела место. Если ошибок нет — содержит 0.

Размер загружаемых файлов может значительно меняться от провайдера к провайдеру. Некоторые администраторы вообще запрещают загрузку файлов. В этом случае файл всё равно может загрузиться, сервер его удалит, а скрипту сообщит, что файл был, но уже удалён.

File nameВ начало страницы

File nameВ начало страницы


Invalid file name characters

Today, almost all programs support long file names and the file name can contain every character (including letters and numbers), except those shown below.

Invalid file name characters

/  : * ? " < > |

File names with spaces

Although all operating systems today support spaces in file names, a command line you may encounter errors because the command line doesn’t know where the file name starts and ends. To prevent errors with file names with spaces surround the file name with quotes when being used in a command line.

  • Information about long file names.
  • How do I copy, move, or rename files with a space in the name?

File names with capital letters

File names can contain uppercase and lowercase characters. However, the operating system that uses the files may be case sensitive. For example, Microsoft Windows is not case sensitive and treats all files the same regardless if they have all lowercase characters or some uppercase characters. However, Linux and macOS are case sensitive, which means the file "readme.txt" and "README.TXT" are treated as two different files even though they have the same file name.

Tip: When designing a web page or uploading any images or other files to the Internet, they are case sensitive. We always recommend keeping all of your file names in all lowercase characters when they are used online to help prevent any confusion or errors.

What is the file name character length limit?

Every operating system has a limit to how many character can be used in a file name that is typically around 255 characters long. When determining the length of a file both the file name and the file extension are used together to get the total length. For example, the file "myfile.txt" is ten characters long. Below is a list of Microsoft Windows versions and their file name character limits.

Windows 10 — 260 character limit.
Windows 8 — 260 character limit.
Windows 7 — 260 character limit.
Windows Vista — 260 character limit.
Windows XP — 255 character limit.
Windows 2000 — 254 character limit.

Note: When renaming a file the full path and file name are used which means each of the directory names, separating slashes, and the file name should not exceed the above set limits (e.g., 260 characters).

Should I be using "file name" or "filename" in my writing?

Today, both "file name" and "filename" are widely used and accepted. The original form of the word was "file name" and "filename" became popular as more people and software programs began to use that version of the word. According to the Microsoft Manual of Style, a file name is "Two words both as an adjective and as a noun when referring to the name of a file. Do not hyphenate."

Note: If you are referring to a programming term such as the FileName property or fileName variable, you should be using the same capitalization of the word in the program you’re describing.


Here is my version of $_FILES rearrange. Unlike other codes here, this working well on any depth of $_FILES.
if (!empty($_FILES)) {
rearrange_files_array(array $array) {
        foreach (
$array as &$value) {
$_array = array();
            foreach (
$value as $prop => $propval) {
                if (
is_array($propval)) {
array_walk_recursive($propval, function(&$item, $key, $value) use($prop) {
$item = array($prop => $item);
$_array = array_replace_recursive($_array, $propval);
                } else {
$_array[$prop] = $propval;
$value = $_array;
'<pre>'.print_r(rearrange_files_array($_FILES), true).'</pre>';
<form method="post" enctype="multipart/form-data" style="clear: both;">
    <div><label>new0</label><input type="file" name="upload1[new][]" /></div>
    <div><label>new1</label><input type="file" name="upload1[new][]" /></div>
    <div><label>update.id11</label><input type="file" name="upload1[update][id11]" /></div>
    <div><label>update.id12</label><input type="file" name="upload1[update][id12]" /></div>
    <hr />
    <div><label>new0</label><input type="file" name="upload2[]" /></div>
    <div><label>new1</label><input type="file" name="upload2[]" /></div>
    <div><label>update.id21</label><input type="file" name="upload2[id21]" /></div>
    <div><label>update.id22</label><input type="file" name="upload2[id22]" /></div>
    <hr />
    <div><label>upload3</label><input type="file" name="upload3" /></div>
    <input type="submit" value="go" />

The output after empty form is posted:
    [upload1] => Array
            [new] => Array
                    [0] => Array
                            [name] =>
                            [type] =>
                            [tmp_name] =>
                            [error] => 4
                            [size] => 0
                    [1] => Array
                            [name] =>
                            [type] =>
                            [tmp_name] =>
                            [error] => 4
                            [size] => 0
            [update] => Array
                    [id11] => Array
                            [name] =>
                            [type] =>
                            [tmp_name] =>
                            [error] => 4
                            [size] => 0
                    [id12] => Array
                            [name] =>
                            [type] =>
                            [tmp_name] =>
                            [error] => 4
                            [size] => 0
    [upload2] => Array
            [0] => Array
                    [name] =>
                    [type] =>
                    [tmp_name] =>
                    [error] => 4
                    [size] => 0
            [1] => Array
                    [name] =>
                    [type] =>
                    [tmp_name] =>
                    [error] => 4
                    [size] => 0
            [id21] => Array
                    [name] =>
                    [type] =>
                    [tmp_name] =>
                    [error] => 4
                    [size] => 0
            [id22] => Array
                    [name] =>
                    [type] =>
                    [tmp_name] =>
                    [error] => 4
                    [size] => 0
    [upload3] => Array
            [name] =>
            [type] =>
            [tmp_name] =>
            [error] => 4
            [size] => 0


Copyright © 2010-2018 Slovar-Vocab.com, AllDic.ru. Англо-русский словарь Онлайн. Бесплатные русско-английские словари и энциклопедия, транскрипция и переводы английских слов и текста на русский.
Free online English dictionaries and words translations with transcription, electronic English-Russian vocabularies, encyclopedia, Russian-English handbooks and translation, thesaurus.