# File Upload Problems

**URL:** <https://www.ruby-forum.com/t/file-upload-problems/57417>\
**Category:** Rails\
**Created:** [April 10, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/file-upload-problems/57417 "2006-04-10T19:42:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [April 10, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/file-upload-problems/57417/1 "2006-04-10T19:42:06Z")

</div>

following the instructions at  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles), I am able  
to upload to an explicit and existing directory (i.e.  
c:\ror\app\public\images\photo.jpg). However, when I try to upload to  
a folder that does not exist, say,  
c:\ror\app\public\image\newfolder\photo.jpg, I get the following error:

Errno::ENOENT in Images#create

No such file or directory -  
C:/Apache/Apache2/htdocs/ror/ae/public/…/config/…/public/images/newfolder/testimage.jpg

RAILS\_ROOT: C:/Apache/Apache2/htdocs/ror/ae/public/…/config/…  
Application Trace | Framework Trace | Full Trace

#{RAILS\_ROOT}/app/models/post.rb:3:in `initialize' #{RAILS_ROOT}/app/models/post.rb:3:in `open’  
#{RAILS\_ROOT}/app/models/post.rb:3:in `save' #{RAILS_ROOT}/app/controllers/images_controller.rb:24:in `create’

Initially, I thought it is a permissions issue on the folder not  
allowing the  
web user to create a directory, but I can’t find a place in the apache  
config or  
.htaccess files to specify the correct permissions.

Here’s my environment:

Ruby version 1.8.2 (i386-mswin32)  
RubyGems version 0.8.11  
Rails version 1.1.0  
Active Record version 1.14.0  
Action Pack version 1.12.0  
Action Web Service version 1.1.0  
Action Mailer version 1.2.0  
Active Support version 1.3.0  
Application root C:/Apache/Apache2/htdocs/ror/ae  
Environment development  
Database adapter mysql  
Apache 2.0.55 w/ fcgi

Thanks for any help you may offer.

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [April 10, 2006, 7:46pm UTC](https://www.ruby-forum.com/t/file-upload-problems/57417/2 "2006-04-10T19:46:43Z")

</div>

I don’t see anything in the Wiki page you cite that handles checking to  
see if the directory exists and creating it if it doesn’t. You would  
need to write code to do that.

However, you really might want to look at the file\_column plugin.

Nick wrote:

> following the instructions at  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles), I am able  
> to upload to an explicit and existing directory (i.e.  
> c:\ror\app\public\images\photo.jpg). However, when I try to upload to  
> a folder that does not exist, say,  
> c:\ror\app\public\image\newfolder\photo.jpg, I get the following error:
> 
> Errno::ENOENT in Images#create
> 
> No such file or directory -  
> C:/Apache/Apache2/htdocs/ror/ae/public/…/config/…/public/images/newfolder/testimage.jpg
> 
> RAILS\_ROOT: C:/Apache/Apache2/htdocs/ror/ae/public/…/config/…  
> Application Trace | Framework Trace | Full Trace
> 
> #{RAILS\_ROOT}/app/models/post.rb:3:in `initialize' #{RAILS_ROOT}/app/models/post.rb:3:in `open’  
> #{RAILS\_ROOT}/app/models/post.rb:3:in `save' #{RAILS_ROOT}/app/controllers/images_controller.rb:24:in `create’
> 
> Initially, I thought it is a permissions issue on the folder not  
> allowing the  
> web user to create a directory, but I can’t find a place in the apache  
> config or  
> .htaccess files to specify the correct permissions.
> 
> Here’s my environment:
> 
> Ruby version 1.8.2 (i386-mswin32)  
> RubyGems version 0.8.11  
> Rails version 1.1.0  
> Active Record version 1.14.0  
> Action Pack version 1.12.0  
> Action Web Service version 1.1.0  
> Action Mailer version 1.2.0  
> Active Support version 1.3.0  
> Application root C:/Apache/Apache2/htdocs/ror/ae  
> Environment development  
> Database adapter mysql  
> Apache 2.0.55 w/ fcgi
> 
> Thanks for any help you may offer.

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [May 8, 2006, 4:27pm UTC](https://www.ruby-forum.com/t/file-upload-problems/57417/3 "2006-05-08T16:27:15Z")

</div>

I have a similar error, but i dont want to use file\_column right now,  
cause i’m in a DBI environment. So, how can i just create a subdirectory  
in public/images?

Nick wrote:

> following the instructions at  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles), I am able  
> to upload to an explicit and existing directory (i.e.  
> c:\ror\app\public\images\photo.jpg). However, when I try to upload to  
> a folder that does not exist, say,  
> c:\ror\app\public\image\newfolder\photo.jpg, I get the following error:
> 
> Errno::ENOENT in Images#create
> 
> No such file or directory -  
> C:/Apache/Apache2/htdocs/ror/ae/public/…/config/…/public/images/newfolder/testimage.jpg

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [April 10, 2006, 8:55pm UTC](https://www.ruby-forum.com/t/file-upload-problems/57417/4 "2006-04-10T20:55:15Z")

</div>

Nick \<nicholas.shiffert@…\> writes:

> No such file or directory -

C:/Apache/Apache2/htdocs/ror/ae/public/…/config/…/public/images/

> web user to create a directory, but I can’t find a place in the apache  
> Action Web Service version 1.1.0  
> Action Mailer version 1.2.0  
> Active Support version 1.3.0  
> Application root C:/Apache/Apache2/htdocs/ror/ae  
> Environment development  
> Database adapter mysql  
> Apache 2.0.55 w/ fcgi
> 
> Thanks for any help you may offer.

Nick,

I would use file\_column as it does so much of the heavy  
lifting for you.

[http://www.kanthak.net/opensource/file\_column/](http://www.kanthak.net/opensource/file_column/)  
[http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn](http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn)

I notice you are on ruby 1.8.2 you should be on 1.8.4 for  
rails 1.1.0. If you use file\_column with 1.8.4 tho you will  
have to run without Rmagick until they come up with a 1.8.4  
compatible version. I would also go to rails 1.1.1.

back on topic, file\_column works a treat!

James
