DataObjects/core.sql
[Pman.Core] / DataObjects / Images.php
index 8959480..56285fc 100644 (file)
@@ -59,17 +59,21 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
         if (isset($q['_remote_upload'])) {
             require_once 'System.php';
             $tmpdir  = System::mktemp("-d remote_upload");
-            $imageInfo = getimagesize($q['_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'] ));
-            #attachment-'.  $r->id
-            $path = $tmpdir . '/' . time() . '#attachment.' . $ext;
-            print_r($path);
-            exit;
-            if(!file_exists($path)){
-               file_put_contents($path, file_get_contents($q['_remote_upload'])); 
+            
+            if (!preg_match("/\." . $ext."$/", $path, $matches)) {
+                rename($path,$path.$ext);
             }
+            
             $this->createFrom($path);
             
             $roo->addEvent("ADD", $this, $this->toEventString());