gpt4 book ai didi

Jquery基本文件上传

转载 作者:行者123 更新时间:2023-12-01 04:57:54 26 4
gpt4 key购买 nike

我一直在研究 Ryan 提出的名为 Jquery 文件上传的截屏视频专业版。但是每次我输入图像时它都不会上传。我不确定我的代码在这里做错了什么。我正在使用谷歌并尝试上传它,但它似乎没有做任何事情

Javascript应用程序.js

//= require jquery
//= require jquery_ujs
//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require_tree .

绘画.js.咖啡

jQuery ->
$('#new_painting').fileupload

浏览次数_form.html.erb

<%= form_for @painting, :html => {:multipart => true} do |f| %>
<div class="field">
<%= f.hidden_field :galley_id %>
</div>
<div class="field">
<%= f.label :image %><br />
<%= f.file_field :image %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

index.html.erb

绘画画廊

<%= form_for Painting.new do |f| %>
<%= f.label :image, "Upload paintings:" %>
<%= f.file_field :image, multiple: true, name: "painting[image]" %>
<% end %>

show.html.erb

<p><%= image_tag @painting.image_url %></p>

<p>
<%= link_to "Edit", edit_painting_path(@painting) %> |
<%= link_to "Destroy", @painting, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "Back to Paintings", paintings_path %>
</p>

Controller

def index
@paintings = Painting.all
end

def show
@painting = Painting.find(params[:id])
end

def new
@painting = Painting.new
end

def create
@painting = Painting.create(params[:painting])
end

def edit
@painting = Painting.find(params[:id])
end

def update
@painting = Painting.find(params[:id])
if @painting.update_attributes(params[:painting])
redirect_to paintings_url, notice: "Painting was successfully updated."
else
render :edit
end
end

def destroy
@painting = Painting.find(params[:id])
@painting.destroy
redirect_to paintings_url, notice: "Painting was successfully destroyed."
end

型号

  attr_accessible :image
mount_uploader :image, ImageUploader

我的主要问题是,当上传任何图片时,它没有提交按钮,并且不确定如何使其工作,我错过了什么吗?

最佳答案

因此,只需在 S3Uploader > 初始化方法中添加时区(即 utc)来解决此问题

更多信息请参见: upload to amazon S3

关于Jquery基本文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13059971/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com