filefield

Submit all of grid rows with Extjs form submit

余生长醉 提交于 2019-12-12 04:54:55
问题 I have a grid panel in a form. Any row of the grid panel have a filefield. I want to send any row (name field and filename field) to server. Model : Ext.define('FM.model.DefineCode', { extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, {name: 'name', type: 'string'}, {name: 'filename', type: 'string'} ], validations: [ {type: 'presence', field: 'id'}, {type: 'presence', field: 'name'}, {type: 'presence', field: 'filename'} ] }); Store: Ext.define('FM.store.DefineCode', { extend:

How to validate “file_fields” in rails 3

时光怂恿深爱的人放手 提交于 2019-12-11 17:54:45
问题 i am a newbie for rails, please guide me. i want to validate "file_field" for image upload. just jpg/png/gif can be upload and specific size like max size (500x500) this is my _form.html.erb <%= form_for(@photo, :html => {:multipart => true} ) do |f| %> <% if @photo.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@photo.errors.count, "error") %> prohibited this photo from being saved:</h2> <ul> <% @photo.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> <

Django Custom image upload field with dynamic path

故事扮演 提交于 2019-12-11 05:04:54
问题 I'm trying to create my own field type for uploading images, it won't be used in the django admin panel. I imagine the syntax would probably look something like: photo = CustomImageField(upload_to='images', width="200", height="200") I want to be able to set the parameters in the field when I upload and save an image. I've looked through the django documentation but I can't find anything about how to do this. So basically, I want to be able to control where the image is uploaded to and the

How to use Django FileField with dynamic Amazon S3 bucket?

喜你入骨 提交于 2019-12-11 00:29:52
问题 I have a Django model with a Filefield, and a default storage using Amazon S3 bucket (via the excellent django-storage). My problem is not to upload files to a dynamic folder path (as we see in many other answers). My problem is deeper and twofold: Files are already inside an Amazon S3 bucket, and I do not want to download-reupload them (worse: I have only a read-access to them). Files are accessible through S3 credentials that could be different from one file to another (that is, files can

Selecting local files using watir-webdriver

China☆狼群 提交于 2019-12-10 16:48:50
问题 I'm attempting to automate the process of selecting a local file from a html page using watir-webdriver I have the following html <body> <form method="post" action="upload" enctype="multipart/form-data"> test file to upload: <input type="file" name="file" size="60" id="test"/> <input type="submit" value="Upload" name="upload" id="upload" /> </form> </body> I'm attempting to click the input with an id of test and set a path to the local file I wish to upload using watir-webdriver. I can use

Change file_field_tag appearance to button appearance

橙三吉。 提交于 2019-12-10 16:28:57
问题 I am working on a Rails project and I want to use file_field_tag but I'd like it looks like a button. I have this: with this code: = file_field_tag 'attachment' I want something like this: and I attempted this: = file_field_tag 'attachment', class: 'btn btn-large btn-warning' but I got this: How can I change the file_field_tag's appearance in order to achieve it looks like a button? 回答1: HTML: <span class="btn btn-large btn-warning btn-file"> Choose File <%= file_field_tag :attachment %> <

Rails 4 add file_field for attachment upload to existing form and controller

牧云@^-^@ 提交于 2019-12-10 15:11:57
问题 I'm super new to rails. Been learning a few weeks now. Please excuse my idiocy. I cannot get my file I've selected to upload. I'm using Rails 4.0.0. I am working on my first application, and I started by following the rails guide for the blog application. I took that and ran with it and am creating something different (bug tracking system) just trying to learn to ropes. So, I've got my form: <%= form_for @post do |f| %> and I've added in my file_field. The display part in from the view looks

customising the look of f.file.field in rails

霸气de小男生 提交于 2019-12-10 02:29:20
问题 <div id="photo_attachment_container"> <%= f.file_field :photo %> </div> Currently this just looks like a button, how can I add some css and customise the look (e.g dimensions background etc) of this button? Thanks 回答1: The HTML file field has been, and remains, one of the most least customizable of the HTML form controls. The other problem is that it is rendered so differently between browsers and OSes. The best way to style these controls is to render the file control as a transparent

How to prevent Django from changing file name when a file with that name already exists?

雨燕双飞 提交于 2019-12-09 06:38:00
问题 In my case I allow user to upload an avatar picture and use user_id as filename, simply. So there will be 1.jpg, 2.jpg, etc. However I found if I upload a new avatar for some account that already has one uploaded, let's say user #10, the new file will be named as "10_1.jpg". This is OKay, however I don't need it and I hope new file could overwrite the old one - it also saves some disk space anyway. I googled and searched but couldn't find a clue. I was hoping there would be an option for

passing a callback as upload_to to FileField

谁都会走 提交于 2019-12-06 05:10:43
问题 I have an abstract model class UploadItem for handling uploaded files. I want each subclass to be able to define the upload_to path. For this, i pass a callback to the constructor of FileField. This is an example: class UploadItem(models.Model): file = models.FileField(upload_to=UploadItem.get_directory) class Meta: abstract = True # I want videos to be storred in 'videos/' directory class Video(UploadItem): def get_directory(self, instance, filename): return 'videos/' But this doesn't work,