jQuery Ajax Multiple File Upload Using PHP

This PHP program will upload multiple files without page reload. This program use HTML5 to select multiple files at a time and also using Ajax and jQuery to upload file to the web server without page refresh. The tool will give an option to select multiple files from local drive, then display the file name and size with an option to remove from the list and then upload the files from the grid list. Click here upload single file without page refresh.

 Multiple File Upload

Include .js and css Files

<script type="text/javascript" src="js/jquery_1.5.2.js">
</scri<script type="text/javascript" src="js/uploader.js"></script>
<link type="text/css" href="css/uploader.css" rel="stylesheet" />

Create the HTML Form

<div class="upload_box">
<form name="fileUpload" id="fileUpload" action="javascript:void(0);" 
<div class="file_browser">
<input type="file" name="multiple_files[]" id="multiple_files" 
class="hide_broswe" multiple /></div>
<div class="file_upload"><input type="submit" value="Upload" 
class="upload_button" /> </div>

<!-- Deleted files will listed here -->
<div class="file_boxes">
<span id="removed_files"></span>

PHP File upload script

if(isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST"){
$file_name = strip_tags($_FILES['upload_file']['name']);
$file_id = strip_tags($_POST['upload_file_ids']);
$file_size = $_FILES['upload_file']['size'];
$files_path = 'uploaded_files/';
$file_location = $files_path . $file_name;

echo $file_id;
echo 'system_error';



Download Code Total Downloads: 13165
26 February

Is it possible to add files one by one also?

I want to validate files upload for 'No file chosen','File size','File type' etc.

Please advice asap.

Thank you!!
25 January
For anyone having a problem running this, 1stly, you need to make the folder 'uploaded_files/' on your server in same location as 'index.php'.
2ndly, my firefox console told me it was cancelling the upload because the form in 'index.php' didn't declare it's method as 'post'. Adding 'method="post"' to the
parameters made it work perfectly.

Very nice little uploader. Thanks a lot!
18 January
vaghela dev

I like this page and i have user this page in my coding thanking you .

Vaghela Dev

17 January
Thankin you
Thanking you. for upload this code.
comments powered by Disqus