Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9296569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:51:35+00:00 2026-06-18T21:51:35+00:00

How to validate the extension of uploaded file when using single uploader for multiple

  • 0

How to validate the extension of uploaded file when using single uploader for multiple file type?

I am using the single model namely Asset containing the attribute file. Uploader is mounted on file attribute. Asset model having one more attribute called feature_id. feature_id refers to features like video, audio, etc.

So, how should I validate the file type with multiple extension whitelist depending upon feature_id value?

Using ruby 1.9 and rails 3.2.11

Any help will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:51:36+00:00Added an answer on June 18, 2026 at 9:51 pm

    I ran into the exact same use case:

    In Asset.rb
    Validate the format of the filename

    validates :asset_file,
                     format:{
                        with: %r{\.(pdf|doc|png)$}i, message: "Wrong file format"
                            }
    

    Use a regular expression to test the file name:

    Here you can play with the regex:
    http://rubular.com/r/Z3roRDDXAf

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to validate the content-type of a file before uploading using JavaScript? I'm not
I need to validate the file type of the uploaded file and should allow
I'm trying to validate the file extension of a input type=file field. But even
hello everyone i want validate the type of file being uploaded on sever to
I got a javascript code like this to validate the file extension for my
I'm trying to validate a simple XML file against an XML schema using the
Right now I have a function which takes my uploaded file, checks the extension,
I want to validate the file extension of file uploads in ASP.NET Web API
I'm using Plupload to allow multiple images to be uploaded to an mvc3 web
I'm using the XDocument.Validate extension method to validate my instance. Is there anyway to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.