On Oct 18, 2012, at 10:51 AM, akvarel wrote:
I was following RailsCasts tutorial JQuery Uploading and I ran into difficulties.
I would like to be able to select several files, preview only the name of the files on the website, remove those, which where selected by mistake and only then upload the neccessary ones in Ruby on Rails.
<br>
I have looked through as well HTML5 and jQuery-File-Upload but I am pretty new to Ruby on Rails and all this everything. If somebody gives me a hint what is better and some primitive codes, I will be really happy
I have got a code but it creates a new Painting and uploads directly, so it doesnt do what I want.
<%= form_for Painting.new do |f| %>
<%= f.label :image, "Upload paintings:" %>
<%= f.file_field :image, multiple: true, name: "painting[image]" %>
<% end %>
I have found as well another code hier but it doesnt support multiple selection and I need the only the name of the file to be previewed.
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
<body>
<form id="form1" runat="server">
<input type='file' onchange="readURL(this);" multiple />
<img id="blah" src="#" alt="your image" />
</form>
</body>
I would be really grateful if somebody helps me to deal with it.
I was following RailsCasts tutorial JQuery Uploading and I ran into difficulties.
I would like to be able to select several files, preview only the name of the files on the website, remove those, which where selected by mistake and only then upload the neccessary ones in Ruby on Rails.
<br>
I have looked through as well HTML5 and jQuery-File-Upload but I am pretty new to Ruby on Rails and all this everything. If somebody gives me a hint what is better and some primitive codes, I will be really happy
I have got a code but it creates a new Painting and uploads directly, so it doesnt do what I want.
<%= form_for Painting.new do |f| %>
<%= f.label :image, "Upload paintings:" %>
<%= f.file_field :image, multiple: true, name: "painting[image]" %>
<% end %>
I have found as well another code hier but it doesnt support multiple selection and I need the only the name of the file to be previewed.
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
<body>
<form id="form1" runat="server">
<input type='file' onchange="readURL(this);" multiple />
<img id="blah" src="#" alt="your image" />
</form>
</body>
I would be really grateful if somebody helps me to deal with it.
<%= form_for @quote, :html => {:multipart => true} do |f| %>
Otherwise the browser is under no compulsion to actually send you the file.
Walter
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.