chakez
chakez

Reputation: 69

Multiple uploads using FuelPHP

I am trying to uplods multiple file using Upload class of Fuel PHP int the form I have 3 input fields for the files. All the files are image with .png extension.

<input type="file" name="file" id="file1">
<input type="file" name="file" id="file2">
<input type="file" name="file" id="file3">

But in my controller the $uploaded_files counts returns only 1. It only returns the last input file. How is this so? Am I missing something? Thanks!

My Controller

$config = array(
'path' => DOCROOT,
'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
'randomize' => true,
);

Upload::process($config);

if (Upload::is_valid()){

Upload::save();

$uploaded_files = Upload::get_files();

}

Upvotes: 0

Views: 404

Answers (1)

Emlyn
Emlyn

Reputation: 862

As I stated in my comment to your question you have named your inputs all the same. If you wish to have an array of files you can use name[] instead of name. This means they will be submitted as an array rather than a single value that gets overwritten by fields with the same name.

Upvotes: 1

Related Questions