我有一个关于Cloudinary直接上传图片的问题。我可以在rails应用程序中使用simple-form和<% = f.cl_image_upload (:file)%>进行设置,但在我选择文件后,它会开始上传。我不喜欢这种方法,我希望在提交表单后立即开始上传。有可能吗?我担心Cloudinary服务器中的文件在我的数据库中没有相应的id。
发布于 2014-06-14 04:56:44
默认实现确实会在选择文件后自动上载文件。大多数用户不会因为删除意外上传的图片而烦恼,因为它们不会占用太多额外的存储空间。但是,如果您不希望在选择时自动上载图像,则可以在fileupload调用中将autoUpload设置为false。例如:
$(document).ready(function() {
$('.cloudinary-fileupload').fileupload({
autoUpload: false
});
});发布于 2014-06-20 00:59:37
我想你可以帮我,实际上,我有这个剧本...
<script>
$(document).ready(function() {
// Cloudinary jQuery integration library uses jQuery File Upload widget
// (see http://blueimp.github.io/jQuery-File-Upload/).
// Any file input field with cloudinary-fileupload class is automatically
// wrapped using the File Upload widget and configured for Cloudinary uploads.
// You can further customize the configuration using .fileupload method
// as we do below.
$(".cloudinary-fileupload")
.fileupload({
// Uncomment the following lines to enable client side image resizing and valiation.
// Make sure cloudinary/processing is included the js file
disableImageMetaDataLoad: true,
disableImageResize: false,
imageMaxWidth: 800,
imageMaxHeight: 800,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|bmp|ico)$/i,
maxFileSize: 20000000, // 20MB
dropZone: "#direct_upload",
start: function (e) {
$(".status").text("Starting upload...");
},
progress: function (e, data) {
$(".status").text("Uploading... " + Math.round((data.loaded * 100.0) / data.total) + "%");
},
fail: function (e, data) {
$(".status").text("Upload failed");
}
})
.off("cloudinarydone").on("cloudinarydone", function (e, data) {
$(".status").text("");
$(".preview").html(
$.cloudinary.image(data.result.public_id, {
format: data.result.format, width: 150, height: 100, crop: "limit"
})
);
});
});
</script>我从javascript开始。上面的脚本运行得很好,但它只是在上传后给我显示了预览。我不喜欢这种方法,因为如果用户更改了预览图像,我将有一个文件上传到Cloudinary,而不是在我的数据库中进行相关注册。将是伟大的,如果可以显示预览,并只是上传后,用户按下提交的形式。
注意:我希望你能理解我,我来自巴西,我的英文写得不是很好。
https://stackoverflow.com/questions/24176080
复制相似问题