. It has also been mounting as a reference for < p > or less.
http://plugmin.co/436/
Even if you try to drag and drop an image,
file://Users/...
I was unable to upload the file successfully.
as described in the file below
console.log("hoge3") is passed, but
console.log("hoge4") does not pass.
I don't know how to do it, and I'm not very familiar with how to debug javascript, so I'm stuck.
I would appreciate your advice.
Thank you for your cooperation.
ruby 2.2.2
rails 4.0.3
Gemfile
source 'https://rails-assets.org'do
gem 'rails-assets-dropzone'
end
app/assets/javascripts/application.js
//=require dropzone
$rake routes
index GET/index(.:format) public#index
root GET/public#index
upload POST / upload (.:format) public# upload
ImageUploader itself has been used elsewhere and has been able to upload images without any problems (although not drag and drop).
class Chat<ActiveRecord::Base
mount_uploader: image, ImageUploader
end
class PublicController <ApplicationController
def index
@chat=Chat.new
end
default upload
chat=Chat.find (params[:id])
chat.attributes=chat_paramas
chat.save
end
def chat_params
param.require(:chat).permit(:user_id,:description,:image)
end
end
app/views/public/index.html.erb
<div class="uploadArea">
<%=link_to"", 'javascript:void(0), class:"uploadZone publish dz-clickable"%>
<p>
Drag and drop images!
</p>
</div>
Also listed below in app/views/public/index.html.erb
*The script part disappeared when I put it in the tag format, so I will write it down as follows. script type="text/javascript" $(function(){ // If you want to post a value for something, var hogeParam="hoge"; // charm Dropzone.autoDiscover=false; Dropzone.options.myAwesomeDropzone={ paramName: "file", // input file name parallelUploads: How many files are uploaded at a time acceptedFiles: 'image/*', // If you only want to upload images maxFiles—Number of files that can be uploaded at a time of 10,// maxFilesize—0.5, // Maximum size of one file (1=1M) dictFileTooBig: "The file is too large. ({{filesize}}MiB).Maximum size: {{maxFilesize}}MiB.", dictInvalidFileType: "Not an image file.", dictMaxFilesExceeded: "You can upload up to 10 files at a time.", }; // url puts the URL path to actually upload the image var myDropzone=new Dropzone(".uploadZone.publish", {url:'}); console.log("hoge3") // If you want to post any value myDropzone.on("sending", function(file, xhr, formData){ console.log("hoge4") formData.append("hoge",hogeParam); }); }); /script
Additional information
Based on what Satoshi Sachin Ohmori pointed out, we have started
I was able to confirm the generation of the instance.
However, even if I drag and drop the image onto the browser, the image file will only be loaded, and I couldn't upload it.
There's no error log...
myDropzone:c URL: URL() _callbacks —Object clickableElements:Array[1] element —a.uploadZone.publish.dz-clickable files —Array [0] hiddenFileInput: input.dz-hidden-input listeners:Array [2] options:Object previewsContainer: a.uploadZone.publish.dz-clickable version: "4.2.0" __proto__:cjavascript ruby-on-rails ruby jquery
Write about how to debug JavaScript.
JavaScript debugs stop at the line where debugger
is written when you put the debugger
method into the code, so you can use the variables and methods you have defined so far.
Sample Code:
var foo="foo";
debugger# Now the browser JavaScript will stop running, so you can make it a foo variable.
He's what we call a breakpoint.
© 2024 OneMinuteCode. All rights reserved.