basic file upload reimplemented

remotes/origin/stable
Arthur Schiwon 14 years ago
parent 6d64a90c24
commit a7da3cd6a0
  1. 8
      files/css/files.css
  2. 1
      files/index.php
  3. 21
      files/js/files.js
  4. 14
      files/templates/index.php

@ -19,6 +19,14 @@
text-decoration: none;
}
#file_upload_form {
display: none;
}
#file_upload_target {
display: none;
}
/* FILE TABLE */
table td.filesize, table td.date

@ -59,6 +59,7 @@ foreach( explode( "/", $dir ) as $i ){
$tmpl = new OC_TEMPLATE( "files", "index", "user" );
$tmpl->assign( "files", $files );
$tmpl->assign( "breadcrumb", $breadcrumb );
$tmpl->assign( 'dir', $dir);
$tmpl->printPage();
?>

@ -36,4 +36,25 @@ $(document).ready(function() {
// Uncheck all
$('.browser input:checkbox').attr('checked', false);
});
// Shows and hides file upload form
$('#file_upload_button').toggle(function() {
$('#file_upload_form').css({"display":"block"});
}, function() {
$('#file_upload_form').css({"display":"none"});
});
$('#file_upload_start').click(function() {
$('#file_upload_target').load(uploadFinished);
});
});
function uploadFinished() {
result = $('#file_upload_target').contents().text();
result = eval("(" + result + ");");
if(result.status == "error") {
alert('An error occcured, upload failed.');
} else {
location.href = 'index.php?dir=' + $('#dir').val();
}
}

@ -7,8 +7,20 @@
<div class="controls">
<p class="actions">
<a href="" title="" class="upload">Upload</a><a href="" title="" class="new-dir">New folder</a><a href="" title="" class="download">Download</a><a href="" title="" class="share">Share</a><a href="" title="" class="delete">Delete</a>
<a href="" title="" class="upload" id="file_upload_button">Upload</a><a
href="" title="" class="new-dir">New folder</a><a href="" title=""
class="download">Download</a><a href="" title="" class="share">Share</a><a
href="" title="" class="delete">Delete</a>
</p>
<div id="file_upload_form">
<form action="ajax/upload.php"
method="post" enctype="multipart/form-data" target="file_upload_target"><input
type="hidden" name="MAX_FILE_SIZE" value="2097152" id="max_upload"><input
type="hidden" name="dir" value="<?php echo $_["dir"] ?>" id="dir"><input
type="file" name="file" id="fileSelector"><input type="submit"
id="file_upload_start" value="Upload" /><iframe id="file_upload_target"
name="file_upload_target" src=""></iframe></form>
</div>
</div>
<p class="nav">

Loading…
Cancel
Save