Problem with file upload

jzw
Wed, 13 Jun 2007 21:17:34 -0000

I have a simple app that allows users to upload image files to the web
server. It works fine on my laptop with Webrick, when I deploy to the
web server it also works fine with webrick.  However, when I try to
connect via Apache, the files get uploaded to the /tmp directory, but
the never make it to the correct directory within the application (/
public/images/photos).  I am sure that this is some permissions
problem with the Apache user (Apache runs as user:nobody,
group:nobody) but it appears that all of the correct permissions are
in place.  Here are the permissions on the photos directory:

drwxrwxr-x  2 jzw    nobody   4096 Jun 13 15:18 photos/

And here is the error:

Errno::EACCES (Permission denied - public/images/photos/28-full.jpg):
    /home/jzw/public_html/my_app/app/models/photo.rb:261:in
`initialize''
    /home/jzw/public_html/my_app/app/models/photo.rb:261:in `open''
    /home/jzw/public_html/my_app/app/models/photo.rb:261:in
`save_full''
    /home/jzw/public_html/my_app/app/models/photo.rb:250:in
`save_file''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:333:in
`send''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:333:in
`callback''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in
`each''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in
`callback''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:243:in
`create_or_update''
    /vendor/rails/activerecord/lib/active_record/base.rb:1548:in
`save_without_validation''
    /vendor/rails/activerecord/lib/active_record/validations.rb:752:in
`save_without_transactions''
    /vendor/rails/activerecord/lib/active_record/transactions.rb:
129:in `save''
    /vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:59:in `transaction''
    /home/jzw/public_html/my_app/public/dispatch.fcgi:34




Errno::EACCES (Permission denied - public/images/photos/28-full.jpg):
    /home/jzw/public_html/my_app/app/models/photo.rb:261:in
`initialize''
    /home/jzw/public_html/my_app/app/models/photo.rb:261:in `open''
    /home/jzw/public_html/my_app/app/models/photo.rb:261:in
`save_full''
    /home/jzw/public_html/my_app/app/models/photo.rb:250:in
`save_file''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:333:in
`send''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:333:in
`callback''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in
`each''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in
`callback''
    /vendor/rails/activerecord/lib/active_record/callbacks.rb:243:in
`create_or_update''
    /vendor/rails/activerecord/lib/active_record/base.rb:1548:in
`save_without_validation''
    /vendor/rails/activerecord/lib/active_record/validations.rb:752:in
`save_without_transactions''
    /vendor/rails/activerecord/lib/active_record/transactions.rb:
129:in `save''
    /vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:59:in `transaction''
    /vendor/rails/activerecord/lib/active_record/transactions.rb:95:in
`transaction''
    /vendor/rails/activerecord/lib/active_record/transactions.rb:
121:in `transaction''
    /vendor/rails/activerecord/lib/active_record/transactions.rb:
129:in `save''
    /home/jzw/public_html/my_app/app/controllers/admin/
photos_controller.rb:79:in `new_or_edit''
    /home/jzw/public_html/my_app/app/controllers/admin/
photos_controller.rb:22:in `new''
    /vendor/rails/actionpack/lib/action_controller/base.rb:1097:in
`send''
    /vendor/rails/actionpack/lib/action_controller/base.rb:1097:in
`perform_action_without_filters''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:723:in
`call_filters''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:713:in
`call_filters''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:661:in
`call''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:661:in
`proxy_before_and_after_filter''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:482:in
`call''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:482:in
`call''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:711:in
`call_filters''
    /vendor/rails/actionpack/lib/action_controller/filters.rb:680:in
`perform_action_without_benchmark''
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:
66:in `perform_action_without_rescue''
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure''
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:
66:in `perform_action_without_rescue''
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:83:in
`perform_action''

Any help is greatly appreciated.