Support:
Ajax File Upload Script Using jQuery
Uploadify is really a great plugins for uploading files or images but i found it hard to implement in cakePHP and CodeIgniter; and also i dont know if my client uses flash; that is why I decided to create this jquery script.
A simple way to upload multiple files or images using jQuery with less manipulation of your native file uploading script.
This file upload script uses iframe for upload process and jQuery for manipulating files and client file validation.
Here's what we gonna do:
Load CSS and Javascript: (Inside <head> tag)
<link href="fileUploader.css" rel="stylesheet" type="text/css" /> <script src="jquery.js" type="text/javascript"></script> <script src="jquery.fileUploader.js" type="text/javascript"></script>
Html: (The native form for uploading your files)
<form action="/path/to/upload/controller" method="post" enctype="multipart/form-data"> <input id="yourInputFileId" name="yourfilename" type="file" /> <br /><br /> <input type="submit" value="Upload" id="pxUpload" /> <input type="reset" value="Clear" id="pxClear" /> </form>
- Input ID's plays an important role for uploading the files
Upload Controller or equivalent back end script that handles the uploading of files
Initialize the plugin script
<script type="text/javascript"> $(function(){ $('#yourInputFileId').fileUploader(); }); </script>
Plugins Option:
$(function(){ $('#yourInputFileId').fileUploader({ imageLoader: '', buttonUpload: '#pxUpload', buttonClear: '#pxClear', successOutput: 'File Uploaded', errorOutput: 'Failed', inputName: 'userfile', inputSize: 30, allowedExtension: 'jpg|jpeg|png|gif' }); });
Option:
| OPTION | DEFAULT VALUE | DESCRIPTION |
| imageLoader | URL of the image loader | |
| buttonUpload | #pxUpload | Selector of the button Upload |
| buttonClear | #pxClear | Selector of the button Clear |
| successOutput | File Uploaded | Ouput to be printed once the file upload is successful |
| errorOutput | Failed | Ouput to be printed once the file upload gets an error |
| inputName | userfile | Use this input name if it is not initialize in the input field |
| allowedExtension | jpg|jpeg|png|gif | allow extensions. Make sure that when using "|" the next string is not empty or else all of file extensions are allowed |
- Test on: IE7+, Firefox 3.0+, Google Chrome

11 Comments
How can I send one input hidden together with input file?
Congratulations for this plugin!
Thanks
if(isset($_POST['uploader'])
and i receive nothing it go to //ouput 'failed' inside
i test it with $_file[uploader][name] $_post['userfile'] and even with if($_post) or if($_file) and nothing.
i understand the constructor but there is a problem with send ...any idea?
That's how i test my file uploading code.
Works really fine for me... If anyone need help with the server side, i'm glad to share it.
Add Your Comment