I've been trying to do a multi file upload with codeigniter 1.7. I'm having issues to say the least!
I know its an old version but that's what I've got to work with.
Can I loop the $_FILES array and upload each one? It doesn't seem to work.
Heres what I've got?
$dir_name = $this->input->post('dir');
$file_path = "./system/application/views/courses/course/";
$full_file_path = $file_path . $dir_name;
if (!file_exists($full_file_path)) {
mkdir($full_file_path, 0777, true);
}
$config['upload_path'] = $full_file_path;
$config['allowed_types'] = 'php|js|html';
$this->load->library('upload');
foreach ($_FILES as $files => $fileObject) //
{
if (!empty($fileObject['name']))
{
$this->upload->initialize($config);
if (!$this->upload->do_upload($files))
{
$errors = $this->upload->display_errors();
}
else
{
echo "It worked";
}
}
}
Is this possible?
This code runs but doesn't upload the files?!
Yes, can loop through $_FILES... although you probably shouldn't name an array an "object", it's a little confusing.
Here's a user manual I found, specifically for the uploads in 1.7, it appears to be substantially similar to 3.0.3. http://www.standoffsystems.com/ci/user_guide/libraries/file_uploading.html
First, make sure your destination folder is set to 777
your
config
is outside theforeach()
and the$this->upload->initialize($config);
is inside, you don't need to initialize it each time since the$config
items are, essentially, static. This isn't likely to fix your issue though.Try this instead:
I see you're not echoing out any errors, what happens if you do?
Hope This will help