]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix that might solve strange uploading issues
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Sat, 16 Apr 2011 23:17:34 +0000 (01:17 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Sat, 16 Apr 2011 23:17:34 +0000 (01:17 +0200)
files/ajax/upload.php
lib/filestorage.php
lib/filesystem.php

index 79b6c0b284ccdc8b2dfdbab49f0793b63b20e001..a1b41d6ba23a7f7512d114dfd3268aeb3f7aff4f 100644 (file)
@@ -21,7 +21,8 @@ if(!empty($dir)) $dir .= '/';
 $target='/' . stripslashes($dir) . $fileName;
 if(isset($_SESSION['username'])
 and $_SESSION['username'] and strpos($dir,'..') === false){
-       if(OC_FILESYSTEM::fromTmpFile($source,$target)){
+       if(OC_FILESYSTEM::fromUploadedFile($source,$target)){
+//     if(OC_FILES::move(dirname($source),basename($source), $dir, $fileName)){
                echo json_encode(array( "status" => "success"));
                exit();
        }
index 799d07da9db5360a8e9b8f6b5de470036c24e9e7..462cc402814f4ba713ebc3ecd9922768ccfd567e 100644 (file)
@@ -69,6 +69,7 @@ class OC_FILESTORAGE{
        public function fopen($path,$mode){}
        public function toTmpFile($path){}//copy the file to a temporary file, used for cross-storage file actions
        public function fromTmpFile($tmpPath,$path){}//copy a file from a temporary file, used for cross-storage file actions
+       public function fromUploadedFile($tmpPath,$path){}//copy a file from a temporary file, used for cross-storage file actions
        public function getMimeType($path){}
        public function delTree($path){}
        public function find($path){}
@@ -388,6 +389,17 @@ die( "oh nooo!" );
                        return false;
                }
        }
+       
+       public function fromUploadedFile($tmpFile,$path){
+               $fileStats = stat($tmpFile);
+               if(move_uploaded_file($tmpFile,$this->datadir.$path)){
+                       touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
+                       $this->notifyObservers($path,OC_FILEACTION_CREATE);
+                       return true;
+               }else{
+                       return false;
+               }
+       }
 
        public function delTree($dir) {
                $dirRelative=$dir;
index 66da4fc3145f17f66f8bda572d491449c36871f1..54b2ad9ce77d31a620bf777ed2e4697b1ab2a3a9 100644 (file)
@@ -339,6 +339,11 @@ class OC_FILESYSTEM{
                        return $storage->fromTmpFile($tmpFile,self::getInternalPath($path));
                }
        }
+       static public function fromUploadedFile($tmpFile,$path){
+               if(self::canWrite($path) and $storage=self::getStorage($path)){
+                       return $storage->fromUploadedFile($tmpFile,self::getInternalPath($path));
+               }
+       }
        static public function getMimeType($path){
                if(self::canRead($path) and $storage=self::getStorage($path)){
                        return $storage->getMimeType(self::getInternalPath($path));