views:

439

answers:

1

Hi All,

I'm using attachment_fu in a rails application to handle file uploads, and i want to save them in a directory in the root of the application called attachments. however, I cannot seem to make this plugin save a file in any other directory than public. Can anyone tell me how to do this?

thx

-C

A: 

Have you tried something a la?

has_attachment :storage => :file_system, :path_prefix => 'attachments/'
Scott
yeah, i've tried several combinations of path_prefix options, and none seem to work unless they start with 'public/'. here's what i get from that option when i try to upload a file :No such file or directory - /storage/daisi/branches/development/public//storage/daisi/branches/development/attachments/0000/0007/524_IMS.yml
Chris Drappier
Strange. I suppose you could always just create an alias in the public directory to a directory at the application root level.I suppose on some level this makes sense though. The web server (whatever it may be) only really knows about the 'public/' directory so all static files need to be included there within. When you upload a file, it needs to be in the 'public/' directory to be addressable via URL.That said, I'm sure there are cases where you might want to upload a file and make it not addressable via URL.
Scott
i actually feel kind of dumb for asking this question now, because i realized that my problem wasn't the plugin itself, but some other code in the file class that the public directory hard-coded in the method that reads the file data in (these are all .yml files). So, your solution is actually correct.
Chris Drappier
Glad to hear you got it resolved. For a second there, I'd talked myself out of my own answer :-P
Scott