我已成功将dropzone.js集成到现有表单中.此表单发布附件和其他输入,如复选框等.
当我提交附有附件的表格时,所有输入都会正确发布.但是,我希望用户可以在没有任何附件的情况下提交表单.Dropzone不允许表单提交,除非有附件.
有没有人知道如何覆盖这个默认行为并提交dropzone.js表单而没有任何附件?谢谢!
$( document ).ready(function () {
Dropzone.options.fileUpload = { // The camelized version of the ID of the form element
// The configuration we've talked about above
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 50,
maxFiles: 50,
addRemoveLinks: true,
clickable: "#clickable",
previewsContainer: ".dropzone-previews",
acceptedFiles: "image/*,application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.spreadsheetml.template, application/vnd.openxmlformats-officedocument.presentationml.template, application/vnd.openxmlformats-officedocument.presentationml.slideshow, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.presentationml.slide, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.wordprocessingml.template, application/vnd.ms-excel.addin.macroEnabled.12, application/vnd.ms-excel.sheet.binary.macroEnabled.12,text/rtf,text/plain,audio/*,video/*,.csv,.doc,.xls,.ppt,application/vnd.ms-powerpoint,.pptx",
// The setting up of the dropzone
init: function() {
var myDropzone = this;
// First change the button to actually tell Dropzone to process …Run Code Online (Sandbox Code Playgroud) 我的理解是外立面被用作依赖注入的替代方案.如果我弄错了,请纠正.不清楚的是何时应该使用其中一种.
每种方法的优点/缺点是什么?我该如何确定何时使用其中一种?
最后,为什么不同时使用?我可以创建一个引用界面的外观.哨兵2似乎是这样写的.有最好的做法吗?
我正在尝试在视图中显示存储在“公共”文件夹之外的图像。这些是简单的概要文件映像,其路径存储在DB中。路径看起来像
/Users/myuser/Documents/Sites/myapp/app/storage/tenants/user2/images/52d645738fb9d-128-Profile (Color) copy.jpg
Run Code Online (Sandbox Code Playgroud)
由于该图像为每个用户存储了一个DB列,因此我的第一个想法是在User模型中创建一个访问器以返回该图像。我试过了:
public function getProfileImage()
{
if(!empty($this->profile_image))
{
return readfile($this->profile_image);
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
这在视图中产生了不可读的字符。我还尝试了file_get_contents()来代替读取文件。关于如何实现的任何建议?