Skip to content

Instantly share code, notes, and snippets.

@jbroadway
Created February 25, 2013 17:49
Show Gist options
  • Save jbroadway/5031735 to your computer and use it in GitHub Desktop.
Save jbroadway/5031735 to your computer and use it in GitHub Desktop.
File chooser in Elefant
<!-- apps/demo/views/file.html -->
{! filemanager/util/browser !}
<form method="post" id="{{_form}}">
<p>
<input type="text" name="file" id="file" value="{{file|quotes}}" />
<input type="submit" id="browse" value="{"Choose an file"}" />
</p>
<p><input type="submit" value="{"Submit"}" /></p>
</form>
<script>
$(function () {
$('#browse').click (function () {
$.filebrowser ({
set_value: '#file'
});
return false;
});
});
</script>
<?php // apps/demo/handlers/file.php
$page->layout = 'admin';
$page->title = __ ('File Chooser Example');
$form = new Form ('post', $this);
echo $form->handle (function ($form) use ($page) {
$page->title = __ ('Your File:');
printf ('<p><a href="%s">%s</a></p>', $_POST['file'], basename ($_POST['file']));
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment