}
-
-
-
+ function beforeInsert($q, $roo)
+ {
+ if (isset($q['_remote_upload'])) {
+ require_once 'System.php';
+ $tmpdir = System::mktemp("-d remote_upload");
+
+ $path = $tmpdir . '/' . basename($q['_remote_upload']);
+ if(!file_exists($path)){
+ file_put_contents($path, file_get_contents($q['_remote_upload']));
+ }
+
+ $imageInfo = getimagesize($path);
+ require_once 'File/MimeType.php';
+ $y = new File_MimeType();
+ $ext = $y->toExt(trim((string) $imageInfo['mime'] ));
+
+ if (!preg_match("/\." . $ext."$/", $path, $matches)) {
+ rename($path,$path.$ext);
+ }
+
+ $this->createFrom($path);
+
+ $roo->addEvent("ADD", $this, $this->toEventString());
+
+ $r = DB_DataObject::factory($this->tableName());
+ $r->id = $this->id;
+ $roo->loadMap($r);
+ $r->limit(1);
+ $r->find(true);
+ $roo->jok($r->URL(-1,'/Images') . '#attachment-'. $r->id);
+ }
+
+ }
/**
// you can normally solve this by giving the storedirectory better perms
// if needed on a dedicated server..
$oldumask = umask(0);
- print_r($dest);
mkdir($dest, 0775, true);
umask($oldumask);
}
$roo->jerr("IMAGE UPLOAD PERMISSION DENIED");
}
+
+
if (!isset($_FILES['imageUpload'])) {
return; // standard update...
}