You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-2Lines changed: 56 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,35 @@ Generate the form with `{{> quickform}}` or `{{#autoform}}` e.g.:
127
127
128
128
Autoform should be wrapped in `{{#if Template.subscriptionsReady }}` which makes sure that template level subscription is ready. Without it the picture preview won't be shown. You can see update mode example [here](https://github.com/VeliovGroup/meteor-autoform-file/issues/9).
129
129
130
+
### Accept configuration
131
+
132
+
##### Usage
133
+
134
+
You can configure the file selector, to only allow certain types of files using the `accept` property:
135
+
136
+
```javascript
137
+
Schemas.Posts=newSimpleSchema({
138
+
title: {
139
+
type:String,
140
+
max:60
141
+
},
142
+
picture: {
143
+
type:String,
144
+
autoform: {
145
+
afFieldInput: {
146
+
type:'fileUpload',
147
+
collection:'Images',
148
+
accept:'image/*'// or use explicit ext names like .png,.jpg
149
+
}
150
+
}
151
+
}
152
+
});
153
+
```
154
+
155
+
The accept values works makes use of the native HTML `accept` attribute. Read more at the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers).
156
+
157
+
Please read the section on **custom upload templates** and how to integrate configs like *accept* to your custom template.
158
+
130
159
### Multiple images // not fully supported yet
131
160
If you want to use an array of images inside you have to define the autoform on on the [schema key](https://github.com/aldeed/meteor-simple-schema#schema-keys)
132
161
@@ -171,13 +200,21 @@ picture: {
171
200
}
172
201
```
173
202
203
+
```html
204
+
<templatename="myFileUpload">
205
+
<ahref="{{file.link}}">{{file.original.name}}</a>
206
+
</template>
207
+
```
208
+
209
+
174
210
### Custom upload template
175
211
176
212
Your custom file upload template data context will be:
177
213
178
214
-*file* - FS.File instance
179
215
-*progress*
180
216
-*status*
217
+
-*config* an object containing several configs to upload behavior, such as `accept`
181
218
- Other fields from [`FileUpload` instance](https://github.com/VeliovGroup/Meteor-Files/wiki/Insert-(Upload)#fileupload-methods-and-properties)
182
219
183
220
```javascript
@@ -194,11 +231,28 @@ picture: {
194
231
```
195
232
196
233
```html
197
-
<templatename="myFilePreview">
198
-
<ahref="{{file.link}}">{{file.original.name}}</a>
234
+
<templatename="myFileUpload">
235
+
{{#with progress}}
236
+
<!-- if there is a progress present, we can use it to determine the upload progress -->
0 commit comments