Skip to content

Commit b7f445d

Browse files
committed
Uploading
1 parent 7fb2489 commit b7f445d

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/controllers/UploadController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace Tsawler\Laravelfilemanager\controllers;
22

33
use App\Http\Controllers\Controller;
4+
use Illuminate\Support\Facades\Config;
45
use Illuminate\Support\Facades\File;
56
use Illuminate\Support\Facades\Input;
67
use Illuminate\Support\Facades\Session;
@@ -39,7 +40,16 @@ function __construct()
3940
*/
4041
public function upload()
4142
{
42-
if (Session::get('type') == "Image")
43+
// sanity check
44+
if ( ! Input::hasFile('file_to_upload'))
45+
{
46+
// there ws no uploded file
47+
return "You must choose a file!";
48+
exit;
49+
}
50+
51+
52+
if (Session::get('lfm_type') == "Images")
4353
{
4454
$file = Input::file('file_to_upload');
4555
$working_dir = Input::get('working_dir');

src/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Route::get('/laravel-filemanager/data', 'Tsawler\Laravelfilemanager\controllers\LfmController@getData');
1313

1414
// upload
15-
Route::post('/laravel-filemanager/upload', 'Tsawler\Laravelfilemanager\controllers\UploadController@upload');
15+
Route::any('/laravel-filemanager/upload', 'Tsawler\Laravelfilemanager\controllers\UploadController@upload');
1616

1717
// list images & files
1818
Route::get('/laravel-filemanager/jsonimages', 'Tsawler\Laravelfilemanager\controllers\LfmController@getImages');

src/views/index.blade.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ class="fa fa-list"></i> List</a>
137137
loadImages();
138138
});
139139
140-
function highlight(x) {
141-
$(".thumbnail-img").not('#' + x).removeClass('highlight');
142-
if ($("#" + x).hasClass('highlight')) {
143-
$("#" + x).removeClass('highlight');
144-
} else {
145-
$("#" + x).addClass('highlight');
146-
}
147-
}
148-
149140
$("#upload-btn").click(function () {
150141
var options = {
151142
beforeSubmit: showRequest,
@@ -159,6 +150,10 @@ function showRequest(formData, jqForm, options) {
159150
160151
function showResponse(responseText, statusText, xhr, $form) {
161152
$("#uploadModal").modal('hide');
153+
$("#upload-btn").html('Upload File...');
154+
if (responseText != "OK"){
155+
notify(responseText);
156+
}
162157
loadImages();
163158
}
164159

0 commit comments

Comments
 (0)