-1

I'm learning PHP and can not find a way to make this work. Did I write correct code to upload multiple images?

I can not think of a reason why this should be wrong.

$imageName = mysql_real_escape_string($_FILES["image, drie1, drie2, drie3, add, strip"]["name"]);    
$imageData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"]));    
$imageType = mysql_real_escape_string($_FILES["image, drie1, drie2, drie3, add, strip"]["type"]);
Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Nyrkl
  • 1

2 Answers2

0

HTML

<form action="file-upload.php" method="post" enctype="multipart/form-data">
  Send these files:<br />
  <input name="userfile[]" type="file" /><br />
  <input name="userfile[]" type="file" /><br />
  <input type="submit" value="Send files" />
</form>

PHP (file-upload.php)

var_dump($_FILES);

This will display the info of the uploaded files

You can add accept attribute to the input to limit the allowed filetypes by extention

online Thomas
  • 8,864
  • 6
  • 44
  • 85
0

Html

<form action="upload.php" method="post" enctype="multipart/form-data">
     <input type="file" name="image_file[]" multiple=""> /* multiple tag is used to upload multiple files */
     <input type="submit" name="Submit" value="Submit" />
</form>

Php

<?php
foreach($_FILES["image_file"]["name"] as $key => $value)
{
    $name = $value;
    $tmp_name = $_FILES["image_file"]["tmp_name"][$key];
    $type = $_FILES["image_file"]["type"][$key];

    echo $name." , ".$tmp_name." , ".$type."\n";
}
?>
Ijas Ahamed N
  • 5,632
  • 5
  • 31
  • 53