basic file upload reimplemented

This commit is contained in:
Arthur Schiwon 2011-04-16 22:56:40 +02:00
parent 6d64a90c24
commit a7da3cd6a0
4 changed files with 43 additions and 1 deletions

View File

@ -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

View File

@ -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();
?>

View File

@ -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();
}
}

View File

@ -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">