HTML5 allows you to upload a complete directory by using directory attribute. This method is more user friendly than any other file uploading method. We can upload a complete directory at a time using this way. At this time, method is working only in Chrome and webkit browsers by using webkitdirectory attribute we can also add mozdirectory attribute for mozila browser support. Here is a simple example to upload directory using PHP.

HTML FORM
<form method="post" enctype="multipart/form-data"> <input type="file" name="files[]" id="files" multiple="" directory="" webkitdirectory="" mozdirectory=""> <input class="button" type="submit" value="Upload" /> </form>
Take a look on the html markup, we need to add box brackets with name attribute. It will collect all files in an array.
PHP
We need to handle uploaded files with php multi upload hander method.
$count = 0; if ($_SERVER['REQUEST_METHOD'] == 'POST'){ foreach ($_FILES['files']['name'] as $i => $name) { if (strlen($_FILES['files']['name'][$i]) > 1) { if (move_uploaded_file($_FILES['files']['tmp_name'][$i], 'upload/'.$name)) { $count++; } } } }
works great.
ReplyDeleteNot working on Internet Explorer!
ReplyDeleteNot really surprising...
DeleteWorks only on modern browsers supporting webkit. Chrome is one.
DeleteGreat, thank you!
ReplyDeleteHi,
ReplyDeleteHow select file OR folder ?
thanks
not working with firefox =(
ReplyDeleteDo not upload directory structure, only files in folder
ReplyDeletecode is working very perfectly under chrome but the problem is in mozila it not work
ReplyDeletehow to file upload multiple folder on server by selecting dropdown
ReplyDeleteI tried to add the attribute mozdirectory but it is not working for firefox
ReplyDeleteCan anyone please give a solution for functional working in all browsers
ReplyDeleteis it possible to add into a mysqli function?
ReplyDeletenot working in mozila . please given any suggestion
ReplyDeletenot working in firefox
ReplyDeleteHello Admin, thank you for enlightening us with your knowledge sharing. PHP has become an inevitable part of web development, and with proper PHP training in Chennai, one can have a strong career in the web development field.
ReplyDeletehóa đơn hợp pháp và bất hợp pháp
ReplyDeletecách lập bảng kê hóa đơn chứng từ bán ra
cách lập bảng kê hóa đơn chứng từ mua vào
kiểm tra thuế tndn chuẩn bị quyết toán thuế
hạch toán khoản truy thu thuế
biện pháp kê khai bổ sung thuế gtgt
cách làm báo cáo tài chính sử dụng hóa đơn
cách viết hóa đơn điều chỉnh tăng giảm
cách tính giá thành theo phương pháp giản đơn
viết hóa đơn điều chỉnh tăng giảm
một số hàm excel thường dùng
kiểm tra báo cáo tài chính
hạch toán công cụ dụng cụ
xử lý và mức phạt cháy hỏng hóa đơn
phân biệt hóa đơn xóa bỏ và hủy
các khoản giảm trừ thuế thu nhập cá nhân
dịch vụ kế toán thuế tại quận gò vấp
dịch vụ kế toán thuế tại quận 2
dịch vụ kế toán thuế tại quận 1
học kế toán thực hành cấp tốc
học kế toán thực hành cấp tốc
học kế toán thực hành tại cầu giấy
học kế toán thực hành tại cầu giấy
học kế toán thực hành tại thanh xuân
học kế toán thực hành tại thanh xuân
lớp học kế toán tổng hợp
ReplyDeletelớp học kế toán thực hành
khóa học kế toán tổng hợp tại vinh nghệ an
trung tâm đào tạo kế toán tại vinh nghệ an
khóa học kế toán thực hành
Khóa học kế toán tổng hợp thực hành tại bắc ninh
Khóa học kế toán tổng hợp thực hành tại hải phòng
Khóa học kế toán tổng hợp thực hành tại tphcm
Khóa học kế toán tổng hợp thực hành tại bình dương
Khóa học kế toán tổng hợp thực hành tại hà đông
Khóa học kế toán tổng hợp thực hành tại cầu giấy
Khóa học kế toán tổng hợp thực hành tại long biên
Khóa học kế toán tổng hợp thực hành tại thanh xuân
dịch vụ kê khai làm báo cáo thuế hàng tháng
dịch vụ kế toán thuế trọn gói chuyên nghiệp giá rẻ
dịch vụ làm báo cáo tài chính giá rẻ
dịch vụ kế toán trọn gói chuyên nghiệp giá rẻ
dịch vụ rà soát dọn dẹp sổ sách kế toán chuyên nghiệp giá rẻ
dịch vụ quyết toán thuế chuyên nghiệp giá rẻ
Only 20 file upload how to increase??
ReplyDeleteI have read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP Training in chennai | PHP Training Course
PHP Training in chennai | Online PHP Course
When uploaded, the directory is not uploaded. Instead, files of that directory are uploaded. I am using Google Chrome.
ReplyDeleteWow. This really made my day. Thanks a lot!
ReplyDeleteJavascript Training in Chennai | HTML5 Online Training | JQuery Online Training
JavaScript Training Courses | Javascript Online Training
Find out new theme free installation https://goo.gl/01sPGc
DeleteWhen uploaded, the directory is not uploaded. Instead, files of that directory are uploaded.how it possible to upload directory also
ReplyDeleteEvery morning, I usually have a habit of logging in to hotmail outlook login facebook and checking out hotmail emailboxes
ReplyDeleteFind out new theme free installation https://goo.gl/01sPGc
DeleteFind out new theme free installation https://goo.gl/01sPGc
ReplyDeleteThanks for sharing this script with us. It is very useful. To know more about PHP visit PHP Training institute in Chennai? | PHP Training | PHP Course in Chennai
ReplyDeleteThank your site! information your share is useful to me!
ReplyDeleteAccessing my site will have many interesting things for you.
beauty face
Mais importante ainda, esses números de usuários também colocariam o Gmail na frente do hotmail.com entrar, executado pela Microsoft, tornando o Gmail o serviço de email mais usado no mundo. Em julho de 2011, a Microsoft disse que o hotmail.com entrar tinha 360 milhões de usuários. A empresa ainda não oferece uma atualização desde então.
ReplyDelete