<textarea name="files[{{fileid}}][content]" id="content_{{fileid}}" cols="80" rows="15" class="content">{{file.getContent}}</textarea>
<div class="row-fluid">
<div class="span9">
-
- <!--
- <label for="upload_{{fileid}}" class="inline">Replace with file upload:</label>
+ <label for="upload_{{fileid}}" class="inline">Replace with upload:</label>
<input type="file" name="files[{{fileid}}][upload]" id="upload_{{fileid}}" class="btn"/>
- -->
</div>
{% if not newfile %}
<div class="span3" style="text-align: right">
{% block title %}Edit paste{% endblock %}
{% block content %}
-<form method="post" action="{{repo.getLink('edit')}}">
+<form method="post" action="{{repo.getLink('edit')}}" enctype="multipart/form-data">
<div class="control-group well pastedata">
<label for="description">Description</label>
<input type="text" name="description" id="description" value="{{repo.getDescription}}"/>
{% block title %}New paste{% endblock %}
{% block content %}
-<form method="post" action="/">
+<form method="post" action="/" enctype="multipart/form-data">
<div class="control-group well pastedata">
<label for="description">Description</label>
<input type="text" name="description" id="description" value="{{description}}"/>
$this->repo->setDescription($postData['description']);
$bChanged = false;
- foreach ($postData['files'] as $arFile) {
- if ($arFile['content'] == '' && $arFile['name'] == '') {
+ foreach ($postData['files'] as $num => $arFile) {
+ $bUpload = false;
+ if ($_FILES['files']['error'][$num]['upload'] == 0) {
+ //valid file upload
+ $bUpload = true;
+ } else if ($arFile['content'] == '' && $arFile['name'] == '') {
//empty (new) file
continue;
}
$name = $this->sanitizeFilename($arFile['name']);
if ($name == '') {
- $name = $this->getNextNumberedFile('phork')
- . '.' . $arFile['type'];
+ if ($bUpload) {
+ $name = $this->sanitizeFilename($_FILES['files']['name'][$num]['upload']);
+ } else {
+ $name = $this->getNextNumberedFile('phork')
+ . '.' . $arFile['type'];
+ }
}
$bNew = false;
->addArgument($file->getFilename())
->execute();
$bChanged = true;
+ } else if ($bUpload) {
+ move_uploaded_file(
+ $_FILES['files']['tmp_name'][$num]['upload'], $file->getPath()
+ );
+ $command = $vc->getCommand('add')
+ ->addArgument($file->getFilename())
+ ->execute();
+ $bChanged = true;
} else if ($bNew || $file->getContent() != $arFile['content']) {
file_put_contents($file->getPath(), $arFile['content']);
$command = $vc->getCommand('add')