WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone please direct me to a resource or give me some pointers on:

  • How to upload a csv file to wordpress (media uploader or alternate methods, ajax powered preferred)
  • Access that file so I can read the contents

I am not looking for a plugin as this is a custom file that I need to read and process inside a plugin. Ideally, this workflow is desired: Choose a file > Click Upload > Plugin accesses the file after upload and processes file content > Plugin deletes the file. Bold steps interest me the most.

share|improve this question
Without describing what "process file contents" means, your question is hard to answer. – chrisguitarguy Feb 3 '13 at 4:40
@chrisguitarguy Basically read the file content and do stuff with it (db and some misc. operations). That part I already have. Thanks! – pistolshrimp Feb 3 '13 at 7:29
up vote 1 down vote accepted
  1. Enable upload of CSV files, which are not in the default allowed files (see here)
  2. Hook into add_attachment action hook to detect when the desired file is uploaded
  3. Do whatever you need to do using that hook, then trigger wp_delete_attachment once the file has been processed.

Depending on what you want to do, it may be beneficial to craft your own upload setup outside the default Media Manager where it would be easier to detect when a file uploaded should be processed by your plugin.

share|improve this answer
I ended up using the default media uploader and am hooking into 'wp_handle_upload', which gives me the file path. Thanks! – pistolshrimp Feb 5 '13 at 2:43
Glad to help! If everything worked out, would you mind marking this question as resolved? Thanks! – Dan Feb 5 '13 at 7:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.