# Multipart post/update without form view

**URL:** <https://www.ruby-forum.com/t/multipart-post-update-without-form-view/122159>\
**Category:** Rails\
**Created:** [December 5, 2007, 1:00am UTC](https://www.ruby-forum.com/t/multipart-post-update-without-form-view/122159 "2007-12-05T01:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nextpulse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/71c47a/32.png) [@nextpulse](https://www.ruby-forum.com/u/nextpulse)\
**Post date:** [December 5, 2007, 1:00am UTC](https://www.ruby-forum.com/t/multipart-post-update-without-form-view/122159/1 "2007-12-05T01:00:00Z")

</div>

I am using attachment\_fu and want to do an update to an attachment.

def update  
…  
attachment.update\_attributes(params[:photo])  
…  
end

this works fine for a form post to action update

But I want to do this in the controller, where I open a local file and  
do the update.

For example:

def myupdate  
…  
photofile = File.open(…)  
…  
attachment.update\_attributes(some photo file)  
…  
end

I’ve seen some long winded way of creating a multipart file piece by  
piece. But is there an easiser way?  
(something like a file\_upload in the test harness)
