Creates a file upload field. If you are using file uploads then you will
also need to set the multipart option for the form tag:
<% form_tag '/upload', :multipart => true do %>
<label for="file">File to Upload</label> <%= file_field_tag "file" %>
<%= submit_tag %>
<% end %>
The specified URL will then be passed a File object containing the selected
file, or if the field was left blank, a StringIO object.
Options
- Creates standard HTML attributes for the tag.
- :disabled - If set to true, the user will not be able to use this
input.
Examples
file_field_tag 'attachment'
# => <input id="attachment" name="attachment" type="file" />
file_field_tag 'avatar', :class => 'profile-input'
# => <input class="profile-input" id="avatar" name="avatar" type="file" />
file_field_tag 'picture', :disabled => true
# => <input disabled="disabled" id="picture" name="picture" type="file" />
file_field_tag 'resume', :value => '~/resume.doc'
# => <input id="resume" name="resume" type="file" value="~/resume.doc" />
file_field_tag 'user_pic', :accept => 'image/png,image/gif,image/jpeg'
# => <input accept="image/png,image/gif,image/jpeg" id="user_pic" name="user_pic" type="file" />
file_field_tag 'file', :accept => 'text/html', :class => 'upload', :value => 'index.html'
# => <input accept="text/html" class="upload" id="file" name="file" type="file" value="index.html" />