[eluser]dallen33[/eluser]
This is in my controller (app.php) (I am loading the Upload.php library already):
Code:
$attach_id = random_string('unique');
for ($i = 1; $i <= 10; $i++)
{
$this->upload->attachments($_FILES['file'.$i]['name'], $_FILES['file'.$i]['tmp_name'], $_FILES['file'.$i]['size'], $_FILES['file'.$i]['type'], $attach_id);
}
This is in my library (Upload.php):
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Upload {
function attachments($fileName, $tmpName, $fileSize, $fileType, $attach_id)
{
$uploadDir = '/Applications/MAMP/htdocs/extras/';
if ($fileSize == 0) { continue; }
$date = date('F j, Y, g:i:sa');
$filename_date = date("YmdHis");
mkdir($uploadDir . $attach_id, 0777);
$filePath = $uploadDir . '/' . $attach_id . '/' . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$this->booking->attachments($attach_id, $fileType, $fileSize, $filePath);
}
}
?>
And this is my model (Booking.php):
Code:
<?php
class Booking extends Model {
function Booking()
{
parent::Model();
}
function attachments($attach_id, $fileType, $fileSize, $filePath)
{
$attach_db_data = array(
'attach_id' => $attach_id ,
'type' => $fileType ,
'size' => $fileSize ,
'path' => $filePath
);
$this->db->insert('attachments', $attach_db_data);
}
}
?>
Basically a user can upload up to 10 files. But when I do this, the browser just sits and times out. Not sure what I'm doing wrong, but this is my first time building a model and a library.