Feature Added : Ability to drag and drop in Chrome
This commit is contained in:
parent
a4f71267f0
commit
79a6d89bcc
|
@ -103,23 +103,33 @@ if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
$directory = '';
|
||||||
if (strpos($dir, '..') === false) {
|
if (strpos($dir, '..') === false) {
|
||||||
$fileCount = count($files['name']);
|
$fileCount = count($files['name']);
|
||||||
for ($i = 0; $i < $fileCount; $i++) {
|
for ($i = 0; $i < $fileCount; $i++) {
|
||||||
|
|
||||||
|
// Get the files directory
|
||||||
|
if(isset($_POST['file_directory']) === true) {
|
||||||
|
$directory = '/'.$_POST['file_directory'];
|
||||||
|
}
|
||||||
|
|
||||||
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
|
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
|
||||||
if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') {
|
if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') {
|
||||||
// append a number in brackets like 'filename (2).ext'
|
// append a number in brackets like 'filename (2).ext'
|
||||||
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
|
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir.$directory), $files['name'][$i]);
|
||||||
} else {
|
} else {
|
||||||
$target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$files['name'][$i]);
|
$target = \OC\Files\Filesystem::normalizePath(stripslashes($dir.$directory).'/'.$files['name'][$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(empty($directory) === true)
|
||||||
|
{
|
||||||
$directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir));
|
$directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir));
|
||||||
if (isset($public_directory)) {
|
if (isset($public_directory)) {
|
||||||
// If we are uploading from the public app,
|
// If we are uploading from the public app,
|
||||||
// we want to send the relative path in the ajax request.
|
// we want to send the relative path in the ajax request.
|
||||||
$directory = $public_directory;
|
$directory = $public_directory;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! \OC\Files\Filesystem::file_exists($target)
|
if ( ! \OC\Files\Filesystem::file_exists($target)
|
||||||
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
|
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
|
||||||
|
|
|
@ -327,7 +327,8 @@ $(document).ready(function() {
|
||||||
// noone set update parameters, we set the minimum
|
// noone set update parameters, we set the minimum
|
||||||
data.formData = {
|
data.formData = {
|
||||||
requesttoken: oc_requesttoken,
|
requesttoken: oc_requesttoken,
|
||||||
dir: $('#dir').val()
|
dir: $('#dir').val(),
|
||||||
|
file_directory: data.files[0]['relativePath'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -879,7 +879,8 @@ $(document).ready(function() {
|
||||||
data.formData = function(form) {
|
data.formData = function(form) {
|
||||||
return [
|
return [
|
||||||
{name: 'dir', value: dir},
|
{name: 'dir', value: dir},
|
||||||
{name: 'requesttoken', value: oc_requesttoken}
|
{name: 'requesttoken', value: oc_requesttoken},
|
||||||
|
{name: 'file_directory', value: data.files[0]['relativePath']}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -956,10 +957,33 @@ $(document).ready(function() {
|
||||||
size += parseInt(file.size);
|
size += parseInt(file.size);
|
||||||
data.context.attr('data-size', size);
|
data.context.attr('data-size', size);
|
||||||
data.context.find('td.filesize').text(humanFileSize(size));
|
data.context.find('td.filesize').text(humanFileSize(size));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
} else {
|
|
||||||
// only append new file if uploaded into the current folder
|
// only append new file if uploaded into the current folder
|
||||||
if (file.directory !== FileList.getCurrentDirectory()) {
|
if (file.directory !== FileList.getCurrentDirectory()) {
|
||||||
|
|
||||||
|
file_directory = file.directory.replace('/','').replace(/\/$/, "").split('/');
|
||||||
|
|
||||||
|
if (file_directory.length == 1) {
|
||||||
|
file_directory = file_directory[0];
|
||||||
|
|
||||||
|
// Get the directory
|
||||||
|
if ($('tr[data-file="'+file_directory+'"]').length == 0)
|
||||||
|
{
|
||||||
|
FileList.addDir(file_directory, 0, new Date(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
file_directory = file_directory[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// update folder size
|
||||||
|
var size = parseInt($('tr[data-file="'+file_directory+'"]').attr('data-size'));
|
||||||
|
size += parseInt(file.size);
|
||||||
|
$('tr[data-file="'+file_directory+'"]').attr('data-size', size);
|
||||||
|
$('tr[data-file="'+file_directory+'"]').find('td.filesize').text(humanFileSize(size));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,10 +617,21 @@ class View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fromTmpFile($tmpFile, $path) {
|
public function fromTmpFile($tmpFile, $path) {
|
||||||
|
|
||||||
if (Filesystem::isValidPath($path)) {
|
if (Filesystem::isValidPath($path)) {
|
||||||
|
|
||||||
|
// Get directory that the file is going into
|
||||||
|
$file_path = \OC_User::getHome(\OC_User::getUser()) . '/files'.substr($path, 0, strrpos($path,'/'));
|
||||||
|
|
||||||
|
// Create the directories if any
|
||||||
|
if(empty($file_path) === false) {
|
||||||
|
mkdir($file_path, 0770, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$tmpFile) {
|
if (!$tmpFile) {
|
||||||
debug_print_backtrace();
|
debug_print_backtrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
$source = fopen($tmpFile, 'r');
|
$source = fopen($tmpFile, 'r');
|
||||||
if ($source) {
|
if ($source) {
|
||||||
$this->file_put_contents($path, $source);
|
$this->file_put_contents($path, $source);
|
||||||
|
|
Loading…
Reference in New Issue