Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To make your life easier, I'd suggest you to use this function to reorder the <code>$_FILES</code> global</p> <pre class="lang-php prettyprint-override"><code>function rotate_array($source_array, $keep_keys = TRUE) { $new_array = array(); foreach ($source_array as $key =&gt; $value) { $value = ($keep_keys === TRUE) ? $value : array_values($value); foreach ($value as $k =&gt; $v) { $new_array[$k][$key] = $v; } } return $new_array; } </code></pre> <p>Then use it in your code:</p> <pre class="lang-php prettyprint-override"><code>$fileCount = 1; $files = rotate_array($_FILES['photos']); foreach ($files as $file) { if (is_uploaded_file($file['tmp_name'])) { $ext = findexts($file['name']); $tempFile = $file['tmp_name']; $uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir; $theFileNameToStore = "equipment_photo_" .$theIds . "_".$fileCount."_". $getCurrentTimeStamp."." .$ext; $targetFile = $uploadDir . $theFileNameToStore; // Validate the filetype $fileParts = pathinfo($file['name']); if (in_array(strtolower($fileParts['extension']), $fileTypes)) { // Save the file //move_uploaded_file($tempFile,$targetFile); // Sometimes move won't work for unknown reasons, try copying, this should work copy($tempFile, $targetFile); echo $theFileNameToStore; } else { // The file type wasn't allowed echo 'Invalid file type.'; } } $fileCount ++; } </code></pre> <p>make sure your <code>phpinfo()</code> shows the correct value for <code>max_file_uploads</code>, <code>upload_max_filesize</code> and <code>post_max_size</code>. Change either on your code, or inside your php.ini file</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload