0

I have a import file page that has a form with a file input element in it, when the user clicks submit, it sends the file, with a JSON document, to a url which uses PHP to read the file and processes it, then inserts the data into a MySQL database.

My question is, what is the best way to go about handling this import feature on the import page(the user-facing interface)? The technologies I am able to use are, Javascript with jQuery for the import file page, and PHP with Codeigniter for the api for serverside processing.

So far, I read people recommending work arounds using iframes, or HTML5 File Api. Is there a better/safer/easier way to go about creating the file upload feature?

1 Answer 1

2

As for usability, for latest browsers i would advice is to use drag & drop upload functionality (that's really cool!) with "old-fashioned" ajax file transfer fallback for old browsers, that is based on flash.

Look at this jQuery plugin for example: http://blueimp.github.com/jQuery-File-Upload/

As for security, i would advice to check file mime type if it is possible (if you have PHP fileinfo extension) with PHP. Unfortunately, i am not familiar with Codeigniter (i use ZF), but i am sure that Codeigniter has filters/validators for files.

Form validation in CI:

http://codeigniter.com/forums/viewthread/74624/#898858

http://keighl.com/post/codeigniter-file-upload-validation

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't go with any of the links you provided, but I did go with drag and drop ajax. I used this code for most of references. html5rocks.com/en/tutorials/file/dndfiles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.