Skip to content

Commit

Permalink
Merge pull request #12 from revelrylabs/master
Browse files Browse the repository at this point in the history
fix file upload for IE11
  • Loading branch information
phirschybar committed Jul 13, 2018
2 parents fdf9a9e + 4812be5 commit 8895198
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions public/js/base.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ $(document).ready(function() {


$('#station-fileupload-form').submit();

$("#postiframe").load(function () {
$iframeContents = $("#postiframe").contents().find('*').first().text();
try {
$iframeContents = $("#postiframe")[0].contentWindow.document.body.innerText;
$results = $.parseJSON($iframeContents);
if ($results.success)
{
Expand Down Expand Up @@ -233,6 +233,9 @@ $(document).ready(function() {
$(this).remove();
scroll(0,0);
}
} catch (e) {
$(this).remove();
}
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/controllers/StationFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function upload()
{
// return an error response if no file is detected, this may be due to the fact that the file is too large.
if (!$this->request->hasFile('uploaded_file')) {
return Response::json(['success' => FALSE, 'reason' => 'No file uploaded or invalid file type.']);
return Response::make(json_encode(['success' => FALSE, 'reason' => 'No file uploaded or invalid file type.']));
}

$panel = new Panel;
Expand Down Expand Up @@ -239,7 +239,7 @@ public function upload()
$bad_image = !$is_an_image || !in_array(strtolower($extension), $allowed_image_extensions);

if ($bad_file) {
return Response::json(['success' => FALSE, 'reason' => 'File is not a valid image.']);
return Response::make(json_encode(['success' => FALSE, 'reason' => 'File is not a valid image.']));
}

$allow_upsize = isset($element['allow_upsize']) && $element['allow_upsize'];
Expand All @@ -258,7 +258,7 @@ public function upload()
$target_directory = isset($element['directory']) ? $element['directory'] : '';

if ($bad_file) {
return Response::json(['success' => FALSE, 'reason' => 'Sorry, this file type is not allowed.']);
return Response::make(json_encode(['success' => FALSE, 'reason' => 'Sorry, this file type is not allowed.']));
}

$this->send_to_s3($new_file_name, $target_directory, $app_config, TRUE);
Expand All @@ -282,7 +282,7 @@ public function upload()
'complete_uri' => $complete_uri,
];

return Response::json($response);
return Response::make(json_encode($response));
}

private function fetch_original($filename, $app_config){
Expand Down

0 comments on commit 8895198

Please sign in to comment.