//$p->toEventString();
}
- function onUploadFromData($filename, $filetype, $data, $roo)
+ function onUploadFromData($data, $roo)
{
- if (empty($filename) || empty($filetype) || empty($data)) {
+ if (empty($data)) {
$this->err = "Missing file details";
return false;
}
require_once 'File/MimeType.php';
$y = new File_MimeType();
- $this->mimetype = $filetype;
+
if (in_array($this->mimetype, array(
'text/application',
'application/octet-stream',
'application/vnd.ms-excel', /// sometimes windows reports csv as excel???
'application/csv-tab-delimited-table', // windows again!!?
))) { // weird tyeps..
- $inf = pathinfo($filename);
+ $inf = pathinfo($this->filename);
$this->mimetype = $y->fromExt($inf['extension']);
}
-
$ext = $y->toExt(trim((string) $this->mimetype ));
$this->filename = empty($this->filename) ?
- $_FILES['imageUpload']['name'] : ($this->filename .'.'. $ext);
+ ('gen-' . date('Y-m-d H:i:s') . '.' . $ext) : ($this->filename .'.'. $ext);
-
-
- if (!$this->createFrom($_FILES['imageUpload']['tmp_name'])) {
+ if (!$this->createFromData($data)) {
return false;
}
return true;
}
- function createFromData($file, $filename=false)
- {
- // copy the file into the storage area..
- if (!file_exists($file) || !filesize($file)) {
- return false;
- }
-
- $filename = empty($filename) ? $file : $filename;
-
- if (empty($this->mimetype)) {
- require_once 'File/MimeType.php';
- $y = new File_MimeType();
- $this->mimetype = $y->fromFilename($filename);
- }
+ function createFromData($data)
+ {
$this->mimetype= strtolower($this->mimetype);
$imgs = @getimagesize($file);
- if (empty($imgs) || empty($imgs[0]) || empty($imgs[1])) {
- // it's a file!!!!
- } else {
+ if (!empty($imgs) && !empty($imgs[0]) && !empty($imgs[1])) {
list($this->width , $this->height) = $imgs;
}
}
- $this->filesize = filesize($file);
+// $this->filesize = filesize($file);
$this->created = date('Y-m-d H:i:s');