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

  • Home
  • SEARCH
  • 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 8746377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:11:02+00:00 2026-06-13T12:11:02+00:00

Have file in @attachment . From debug: datafile=>#<ActionDispatch::Http::UploadedFile:0x3eee9c0 @original_filename=filename.jpg, @content_type=image/jpeg, @headers=Content-Disposition: form-data; name=\datafile\; filename=\filename.jpg\\r\nContent-Type:

  • 0

Have file in @attachment. From debug:

"datafile"=>#<ActionDispatch::Http::UploadedFile:0x3eee9c0        @original_filename="filename.jpg",
 @content_type="image/jpeg",
 @headers="Content-Disposition: form-data; name=\"datafile\";   filename=\"filename.jpg\"\r\nContent-Type: image/jpeg\r\n",
 @tempfile=#<File:C:/Users/.../RackMultipart20121026-2452-g369hf>>,

It was uploaded via a user form.

I’m trying to attach it to an email:

...
attachments[@attachment.original_filename] = @attachment
mail(:to => "email@email.com", :subject => "test", :from => @fromaddress)

Which errors:

undefined method `length’ for #

I have also tried

attachments[@attachment.original_filename] = @attachment.tempfile

Which errors:

undefined method `[]' for #<Tempfile:0x5629e48>

@attachment.original_filename returns the proper filename (“filename.jpg” in example)

Anything obvious?

  • 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-13T12:11:03+00:00Added an answer on June 13, 2026 at 12:11 pm

    Unless you save the uploaded file to some place, it’s a bit limited, what you can do with it (for security reasons – you are supposed to validate the upload and then store the file).

    But you should be able to read the file:

    attachments[@attachment.original_filename] = @attachment.read
    

    Note: I haven’t tested this, maybe you need to read from the @attachment.tempfile

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

Sidebar

Related Questions

here's the code I have: Response.Clear(); Response.AddHeader(content-disposition, attachment; filename=file.xlsx); Response.ContentType = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; Response.BinaryWrite(pck.GetAsByteArray()); Response.End();
I have a file attachment class (FileAttachment) which is used in several other classes.
i have an action that return a file content. i added: Response.AddHeader(Content-Disposition, attactment; filename:\
I have this code here where I retrieve an attachment from an Email Message
I have a file download script that I have written, which reads files from
I have an Excel Add-In file I'm publishing on an intranet (plain ol' HTTP
I want to download a file from server to a local host. i have
I have a pdf file attachment saved in the cloud. The file is attached
So i have this code that works perfectly without the 'file attachment' and sends
i have a form where i have an input file to place an attachment.

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.