[development] D7 File API

Peter Anderson list at panda.id.au
Mon May 2 02:21:45 UTC 2011

Hi everyone,

I'm upgrading my D6 module to D7 and am trying to work out the best way 
to implement the new File API...
My module allows users to either upload a file from their computer, or 
enter the relative path of a file already on the server (e.g. 
/sites/default/themes/...). The relative path to this file is then 
stored in the DB.

I'm not sure what to store in the database in the D7 version: the file 
URI (public://my_file.png) or the relative path as per the D6 version 
The reasons I'm not sure are as follows:
- Storing the File URI seems to be the obvious choice as that seems to 
be the default now
- But how would I allow users to enter the path of a file already on the 
server in, say, their theme folder?
- Storing the relative path is how I used to do it, so is easier
- But then how do I change a relative path to a File URI when required 
(e.g. by the image_style_url() function)?

Any assistance or advice would be much appreciated!

Kind regards,
Peter Anderson.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110502/52a0d721/attachment.html 

More information about the development mailing list