Hello,

I'm looking for a way to upload an image without uploading it through a node.
I just need the path in my module's custom table and the image itself in the /files directory.

Any idea ?

Comments

larowlan’s picture

Hi, you need to create a file field (see http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....)
You should look to the upload module (http://api.drupal.org/api/drupal/modules--upload--upload.module/function...) to see how best to handle the submit function on your form including file extension checking etc. Note that you should look at upload_save as well (http://api.drupal.org/api/drupal/modules--upload--upload.module/function...) to make sure you set your files as permanent, otherwise they will be removed on you at a later date!
Your data (path etc) will be saved in the files table so you just need to keep the fid in your custom table.

Lee Rowlands

--author="larowlan <larowlan@395439.no-reply.drupal.org>"