Added jQuery file upload plugin
This commit is contained in:
parent
3fa13965cd
commit
23216cf38c
2 changed files with 21 additions and 2 deletions
|
|
@ -61,6 +61,13 @@ class PackagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_image
|
def upload_image
|
||||||
"uploaded"
|
#render text: params[:image].to_json
|
||||||
|
#render text: params.to_json
|
||||||
|
@package = Package.find_by(name: params[:name])
|
||||||
|
new_screenshot = @package.screenshots.create(params[:screenshot])
|
||||||
|
@packages.save
|
||||||
|
#new_screenshot.image = params[:image]
|
||||||
|
|
||||||
|
render text: "File has been uploaded successfully"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
//= form_for @package, :url => upload_image_path, :html => { :multipart => true } do |form|
|
//= form_for @package, :url => upload_image_path, :html => { :multipart => true } do |form|
|
||||||
//= form.file_field :image
|
//= form.file_field :image
|
||||||
|
|
||||||
= form_for Screenshot.new, url: upload_image_path, html: { multipart: true } do |f|
|
= form_for :screenshot, url: upload_image_path, html: { multipart: true } do |f|
|
||||||
= f.label :image, 'Upload new screenshot'
|
= f.label :image, 'Upload new screenshot'
|
||||||
= f.file_field :image, id: 'fileupload', multiple: true
|
= f.file_field :image, id: 'fileupload', multiple: true
|
||||||
= f.submit 'Save'
|
= f.submit 'Save'
|
||||||
|
|
@ -50,6 +50,18 @@
|
||||||
|
|
||||||
//a.button.radius.expand href=upload_package_by_name_path(name: @package.name) Upload a new screenshot
|
//a.button.radius.expand href=upload_package_by_name_path(name: @package.name) Upload a new screenshot
|
||||||
|
|
||||||
|
javascript:
|
||||||
|
$(function () {
|
||||||
|
$('#fileupload').fileupload({
|
||||||
|
dataType: 'json',
|
||||||
|
done: function (e, data) {
|
||||||
|
$.each(data.result.files, function (index, file) {
|
||||||
|
$('<p/>').text(file.name).appendTo(document.body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: Enable comment form
|
// TODO: Enable comment form
|
||||||
//javascript:
|
//javascript:
|
||||||
// $('#comment-summary').on( 'input', function() {
|
// $('#comment-summary').on( 'input', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue